passphera-core 0.23.0__tar.gz → 0.25.0__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.23.0 → passphera_core-0.25.0}/PKG-INFO +1 -1
- {passphera_core-0.23.0 → passphera_core-0.25.0}/passphera_core/application/generator.py +8 -0
- {passphera_core-0.23.0 → passphera_core-0.25.0}/passphera_core/entities.py +18 -9
- {passphera_core-0.23.0 → passphera_core-0.25.0}/passphera_core/exceptions.py +6 -0
- {passphera_core-0.23.0 → passphera_core-0.25.0}/passphera_core.egg-info/PKG-INFO +1 -1
- {passphera_core-0.23.0 → passphera_core-0.25.0}/setup.py +1 -1
- {passphera_core-0.23.0 → passphera_core-0.25.0}/README.md +0 -0
- {passphera_core-0.23.0 → passphera_core-0.25.0}/passphera_core/__init__.py +0 -0
- {passphera_core-0.23.0 → passphera_core-0.25.0}/passphera_core/application/__init__.py +0 -0
- {passphera_core-0.23.0 → passphera_core-0.25.0}/passphera_core/application/password.py +0 -0
- {passphera_core-0.23.0 → passphera_core-0.25.0}/passphera_core/interfaces.py +0 -0
- {passphera_core-0.23.0 → passphera_core-0.25.0}/passphera_core/utilities.py +0 -0
- {passphera_core-0.23.0 → passphera_core-0.25.0}/passphera_core.egg-info/SOURCES.txt +0 -0
- {passphera_core-0.23.0 → passphera_core-0.25.0}/passphera_core.egg-info/dependency_links.txt +0 -0
- {passphera_core-0.23.0 → passphera_core-0.25.0}/passphera_core.egg-info/requires.txt +0 -0
- {passphera_core-0.23.0 → passphera_core-0.25.0}/passphera_core.egg-info/top_level.txt +0 -0
- {passphera_core-0.23.0 → passphera_core-0.25.0}/setup.cfg +0 -0
@@ -40,6 +40,14 @@ class ResetPropertyUseCase:
|
|
40
40
|
return generator_entity
|
41
41
|
|
42
42
|
|
43
|
+
class GetCharacterReplacementUseCase:
|
44
|
+
def __init__(self, generator_repository: GeneratorRepository):
|
45
|
+
self.generator_repository: GeneratorRepository = generator_repository
|
46
|
+
|
47
|
+
def __call__(self, character: str) -> str:
|
48
|
+
return self.generator_repository.get().get_character_replacement(character)
|
49
|
+
|
50
|
+
|
43
51
|
class SetCharacterReplacementUseCase:
|
44
52
|
def __init__(self, generator_repository: GeneratorRepository):
|
45
53
|
self.generator_repository: GeneratorRepository = generator_repository
|
@@ -8,6 +8,8 @@ from cipherspy.cipher import *
|
|
8
8
|
from cipherspy.exceptions import InvalidAlgorithmException
|
9
9
|
from cipherspy.utilities import generate_salt, derive_key
|
10
10
|
|
11
|
+
from passphera_core.exceptions import InvalidPropertyNameException
|
12
|
+
|
11
13
|
|
12
14
|
@dataclass
|
13
15
|
class Password:
|
@@ -112,7 +114,7 @@ class Generator:
|
|
112
114
|
:return: None
|
113
115
|
"""
|
114
116
|
if prop not in {"shift", "multiplier", "key", "algorithm", "prefix", "postfix"}:
|
115
|
-
raise
|
117
|
+
raise InvalidPropertyNameException(prop)
|
116
118
|
if prop in ["shift", "multiplier"]:
|
117
119
|
value = int(value)
|
118
120
|
setattr(self, prop, value)
|
@@ -128,31 +130,38 @@ class Generator:
|
|
128
130
|
:return: None
|
129
131
|
"""
|
130
132
|
if prop not in {"shift", "multiplier", "key", "algorithm", "prefix", "postfix"}:
|
131
|
-
raise
|
132
|
-
|
133
|
+
raise InvalidPropertyNameException(prop)
|
133
134
|
setattr(self, prop, self._default_properties[prop])
|
134
135
|
if prop == "algorithm":
|
135
136
|
self.get_algorithm()
|
136
137
|
self.updated_at = datetime.now(timezone.utc)
|
138
|
+
|
139
|
+
def get_character_replacement(self, character: str) -> str:
|
140
|
+
"""
|
141
|
+
Get the replacement string for a given character
|
142
|
+
:param character: The character to get its replacement
|
143
|
+
:return: str: The replacement string for the character, or the character itself if no replacement exists
|
144
|
+
"""
|
145
|
+
return self.characters_replacements.get(character, character)
|
137
146
|
|
138
|
-
def replace_character(self,
|
147
|
+
def replace_character(self, character: str, replacement: str) -> None:
|
139
148
|
"""
|
140
149
|
Replace a character with another character or set of characters
|
141
150
|
Eg: pg.replace_character('a', '@1')
|
142
|
-
:param
|
151
|
+
:param character: The character to be replaced
|
143
152
|
:param replacement: The (character|set of characters) to replace the first one
|
144
153
|
:return: None
|
145
154
|
"""
|
146
|
-
self.characters_replacements[
|
155
|
+
self.characters_replacements[character[0]] = replacement
|
147
156
|
self.updated_at = datetime.now(timezone.utc)
|
148
157
|
|
149
|
-
def reset_character(self,
|
158
|
+
def reset_character(self, character: str) -> None:
|
150
159
|
"""
|
151
160
|
Reset a character to its original value (remove its replacement from characters_replacements)
|
152
|
-
:param
|
161
|
+
:param character: The character to be reset to its original value
|
153
162
|
:return: None
|
154
163
|
"""
|
155
|
-
self.characters_replacements.pop(
|
164
|
+
self.characters_replacements.pop(character, None)
|
156
165
|
self.updated_at = datetime.now(timezone.utc)
|
157
166
|
|
158
167
|
def generate_password(self, text: str) -> str:
|
@@ -17,3 +17,9 @@ class DuplicatePasswordException(Exception):
|
|
17
17
|
if hasattr(password, 'context') and password.context:
|
18
18
|
return f"Password for context '{password.context}' already exists"
|
19
19
|
return "Duplicate password detected"
|
20
|
+
|
21
|
+
|
22
|
+
class InvalidPropertyNameException(Exception):
|
23
|
+
def __init__(self, property_name: str) -> None:
|
24
|
+
self.property_name = property_name
|
25
|
+
super().__init__(f"Invalid property name '{property_name}'")
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{passphera_core-0.23.0 → passphera_core-0.25.0}/passphera_core.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|