passphera-core 0.31.0__tar.gz → 0.32.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {passphera_core-0.31.0 → passphera_core-0.32.1}/PKG-INFO +1 -1
- {passphera_core-0.31.0 → passphera_core-0.32.1}/passphera_core/entities.py +6 -9
- {passphera_core-0.31.0 → passphera_core-0.32.1}/passphera_core/utilities.py +2 -2
- {passphera_core-0.31.0 → passphera_core-0.32.1}/passphera_core.egg-info/PKG-INFO +1 -1
- {passphera_core-0.31.0 → passphera_core-0.32.1}/setup.py +1 -1
- {passphera_core-0.31.0 → passphera_core-0.32.1}/README.md +0 -0
- {passphera_core-0.31.0 → passphera_core-0.32.1}/passphera_core/__init__.py +0 -0
- {passphera_core-0.31.0 → passphera_core-0.32.1}/passphera_core/exceptions.py +0 -0
- {passphera_core-0.31.0 → passphera_core-0.32.1}/passphera_core.egg-info/SOURCES.txt +0 -0
- {passphera_core-0.31.0 → passphera_core-0.32.1}/passphera_core.egg-info/dependency_links.txt +0 -0
- {passphera_core-0.31.0 → passphera_core-0.32.1}/passphera_core.egg-info/requires.txt +0 -0
- {passphera_core-0.31.0 → passphera_core-0.32.1}/passphera_core.egg-info/top_level.txt +0 -0
- {passphera_core-0.31.0 → passphera_core-0.32.1}/setup.cfg +0 -0
@@ -1,5 +1,4 @@
|
|
1
1
|
from dataclasses import dataclass, field
|
2
|
-
from datetime import datetime, timezone
|
3
2
|
|
4
3
|
from cipherspy.cipher import *
|
5
4
|
from cipherspy.exceptions import InvalidAlgorithmException
|
@@ -12,7 +11,7 @@ _cipher_registry: dict = {
|
|
12
11
|
'playfair': PlayfairCipherAlgorithm,
|
13
12
|
'hill': HillCipherAlgorithm,
|
14
13
|
}
|
15
|
-
_default_properties: dict[str,
|
14
|
+
_default_properties: dict[str, object] = {
|
16
15
|
"shift": 3,
|
17
16
|
"multiplier": 3,
|
18
17
|
"key": "hill",
|
@@ -97,7 +96,6 @@ class Generator:
|
|
97
96
|
setattr(self, prop, value)
|
98
97
|
if prop == "algorithm":
|
99
98
|
self.get_algorithm()
|
100
|
-
self.updated_at = datetime.now(timezone.utc)
|
101
99
|
|
102
100
|
@check_property_name
|
103
101
|
def reset_property(self, prop: str) -> None:
|
@@ -110,8 +108,7 @@ class Generator:
|
|
110
108
|
setattr(self, prop, _default_properties[prop])
|
111
109
|
if prop == "algorithm":
|
112
110
|
self.get_algorithm()
|
113
|
-
|
114
|
-
|
111
|
+
|
115
112
|
def get_character_replacement(self, character: str) -> str:
|
116
113
|
"""
|
117
114
|
Get the replacement string for a given character
|
@@ -129,7 +126,6 @@ class Generator:
|
|
129
126
|
:return: None
|
130
127
|
"""
|
131
128
|
self.characters_replacements[character[0]] = replacement
|
132
|
-
self.updated_at = datetime.now(timezone.utc)
|
133
129
|
|
134
130
|
def reset_character_replacement(self, character: str) -> None:
|
135
131
|
"""
|
@@ -138,7 +134,6 @@ class Generator:
|
|
138
134
|
:return: None
|
139
135
|
"""
|
140
136
|
self.characters_replacements.pop(character, None)
|
141
|
-
self.updated_at = datetime.now(timezone.utc)
|
142
137
|
|
143
138
|
def generate_password(self, text: str) -> str:
|
144
139
|
"""
|
@@ -150,7 +145,8 @@ class Generator:
|
|
150
145
|
secondary_algorithm: AffineCipherAlgorithm = AffineCipherAlgorithm(self.shift, self.multiplier)
|
151
146
|
intermediate: str = secondary_algorithm.encrypt(f"{self.prefix}{text}{self.postfix}")
|
152
147
|
password: str = main_algorithm.encrypt(intermediate)
|
153
|
-
|
148
|
+
for char, repl in self.characters_replacements.items():
|
149
|
+
password = password.replace(char, repl)
|
154
150
|
return ''.join(c.upper() if c in text else c for c in password)
|
155
151
|
|
156
152
|
def to_dict(self) -> dict:
|
@@ -168,4 +164,5 @@ class Generator:
|
|
168
164
|
def from_dict(self, data: dict) -> None:
|
169
165
|
"""Convert a dictionary to a Generator entity."""
|
170
166
|
for key, value in data.items():
|
171
|
-
|
167
|
+
if key in _default_properties or key == "characters_replacements":
|
168
|
+
setattr(self, key, value)
|
@@ -2,8 +2,8 @@ from passphera_core.exceptions import InvalidPropertyNameException
|
|
2
2
|
|
3
3
|
|
4
4
|
def check_property_name(func):
|
5
|
-
def wrapper(self, prop,
|
5
|
+
def wrapper(self, prop, *args, **kwargs):
|
6
6
|
if prop not in {"shift", "multiplier", "key", "algorithm", "prefix", "postfix", "character_replacements"}:
|
7
7
|
raise InvalidPropertyNameException(prop)
|
8
|
-
return func(self, prop,
|
8
|
+
return func(self, prop, *args, **kwargs)
|
9
9
|
return wrapper
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{passphera_core-0.31.0 → passphera_core-0.32.1}/passphera_core.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|