passphera-core 0.25.0__py3-none-any.whl → 0.25.2__py3-none-any.whl
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/entities.py +19 -18
- passphera_core/exceptions.py +2 -5
- {passphera_core-0.25.0.dist-info → passphera_core-0.25.2.dist-info}/METADATA +1 -1
- {passphera_core-0.25.0.dist-info → passphera_core-0.25.2.dist-info}/RECORD +6 -6
- {passphera_core-0.25.0.dist-info → passphera_core-0.25.2.dist-info}/WHEEL +0 -0
- {passphera_core-0.25.0.dist-info → passphera_core-0.25.2.dist-info}/top_level.txt +0 -0
passphera_core/entities.py
CHANGED
@@ -11,6 +11,22 @@ from cipherspy.utilities import generate_salt, derive_key
|
|
11
11
|
from passphera_core.exceptions import InvalidPropertyNameException
|
12
12
|
|
13
13
|
|
14
|
+
_cipher_registry: dict[str, BaseCipherAlgorithm] = {
|
15
|
+
'caesar': CaesarCipherAlgorithm,
|
16
|
+
'affine': AffineCipherAlgorithm,
|
17
|
+
'playfair': PlayfairCipherAlgorithm,
|
18
|
+
'hill': HillCipherAlgorithm,
|
19
|
+
}
|
20
|
+
_default_properties: dict[str, str] = {
|
21
|
+
"shift": 3,
|
22
|
+
"multiplier": 3,
|
23
|
+
"key": "hill",
|
24
|
+
"algorithm": "hill",
|
25
|
+
"prefix": "secret",
|
26
|
+
"postfix": "secret"
|
27
|
+
}
|
28
|
+
|
29
|
+
|
14
30
|
@dataclass
|
15
31
|
class Password:
|
16
32
|
id: UUID = field(default_factory=uuid4)
|
@@ -48,21 +64,6 @@ class Password:
|
|
48
64
|
|
49
65
|
@dataclass
|
50
66
|
class Generator:
|
51
|
-
_cipher_registry: dict[str, BaseCipherAlgorithm] = field(default_factory=lambda: {
|
52
|
-
'caesar': CaesarCipherAlgorithm,
|
53
|
-
'affine': AffineCipherAlgorithm,
|
54
|
-
'playfair': PlayfairCipherAlgorithm,
|
55
|
-
'hill': HillCipherAlgorithm,
|
56
|
-
}, init=False)
|
57
|
-
_default_properties: dict[str, str] = field(default_factory=lambda:{
|
58
|
-
"shift": 3,
|
59
|
-
"multiplier": 3,
|
60
|
-
"key": "hill",
|
61
|
-
"algorithm": "hill",
|
62
|
-
"prefix": "secret",
|
63
|
-
"postfix": "secret"
|
64
|
-
}, init=False)
|
65
|
-
|
66
67
|
id: UUID = field(default_factory=uuid4)
|
67
68
|
created_at: datetime = field(default_factory=datetime.now)
|
68
69
|
updated_at: datetime = field(default_factory=datetime.now)
|
@@ -79,9 +80,9 @@ class Generator:
|
|
79
80
|
Get the primary algorithm used to cipher the password
|
80
81
|
:return: BaseCipherAlgorithm: The primary algorithm used for the cipher
|
81
82
|
"""
|
82
|
-
if self.algorithm.lower() not in
|
83
|
+
if self.algorithm.lower() not in _cipher_registry:
|
83
84
|
raise InvalidAlgorithmException(self.algorithm)
|
84
|
-
return
|
85
|
+
return _cipher_registry[self.algorithm.lower()]
|
85
86
|
|
86
87
|
def get_properties(self) -> dict:
|
87
88
|
"""
|
@@ -131,7 +132,7 @@ class Generator:
|
|
131
132
|
"""
|
132
133
|
if prop not in {"shift", "multiplier", "key", "algorithm", "prefix", "postfix"}:
|
133
134
|
raise InvalidPropertyNameException(prop)
|
134
|
-
setattr(self, prop,
|
135
|
+
setattr(self, prop, _default_properties[prop])
|
135
136
|
if prop == "algorithm":
|
136
137
|
self.get_algorithm()
|
137
138
|
self.updated_at = datetime.now(timezone.utc)
|
passphera_core/exceptions.py
CHANGED
@@ -1,19 +1,16 @@
|
|
1
|
-
from passphera_core.entities import Password
|
2
|
-
|
3
|
-
|
4
1
|
class PasswordNotFoundException(Exception):
|
5
2
|
def __init__(self) -> None:
|
6
3
|
super().__init__("Password not found")
|
7
4
|
|
8
5
|
|
9
6
|
class DuplicatePasswordException(Exception):
|
10
|
-
def __init__(self, password
|
7
|
+
def __init__(self, password) -> None:
|
11
8
|
self.password = password
|
12
9
|
message = self._build_message(password)
|
13
10
|
super().__init__(message)
|
14
11
|
|
15
12
|
@staticmethod
|
16
|
-
def _build_message(password
|
13
|
+
def _build_message(password) -> str:
|
17
14
|
if hasattr(password, 'context') and password.context:
|
18
15
|
return f"Password for context '{password.context}' already exists"
|
19
16
|
return "Duplicate password detected"
|
@@ -1,12 +1,12 @@
|
|
1
1
|
passphera_core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
passphera_core/entities.py,sha256=
|
3
|
-
passphera_core/exceptions.py,sha256=
|
2
|
+
passphera_core/entities.py,sha256=xl9HAZA9SFgO5xt5bsyGbcH508auU33J-7D52bn1wbI,7550
|
3
|
+
passphera_core/exceptions.py,sha256=Tqb-FKJ1_JfX5gSC8Wc0CP84AhwouvnP2gkg83xAlUY,786
|
4
4
|
passphera_core/interfaces.py,sha256=DpHFh_vnamORf69P1dwLrZ8AYZPcYIol0Lq_VKRBkXc,855
|
5
5
|
passphera_core/utilities.py,sha256=n7cAVox-yGd60595RjLvrGKSGqFQRm279YqKS3-R1X0,748
|
6
6
|
passphera_core/application/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
7
|
passphera_core/application/generator.py,sha256=hBSk6vktJ2KPxzKSRnH_WVnCvg7vOHVzN-TQ5GdgXEQ,2769
|
8
8
|
passphera_core/application/password.py,sha256=9wsSz3uMWEZCgfnX5V7WYiWp2OqjSmsn6OSWK4HIIfo,2876
|
9
|
-
passphera_core-0.25.
|
10
|
-
passphera_core-0.25.
|
11
|
-
passphera_core-0.25.
|
12
|
-
passphera_core-0.25.
|
9
|
+
passphera_core-0.25.2.dist-info/METADATA,sha256=X0VrNDvEBZOQPMvaYd3n4hop0HlN-yAkNEGhBlUu50k,868
|
10
|
+
passphera_core-0.25.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
11
|
+
passphera_core-0.25.2.dist-info/top_level.txt,sha256=aDUX2iWGOyfzyf6XakLWTbgeWqNrypMHO074Qratyds,15
|
12
|
+
passphera_core-0.25.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|