passphera-core 0.4.0__py3-none-any.whl → 0.5.0__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/generator.py +14 -10
- {passphera_core-0.4.0.dist-info → passphera_core-0.5.0.dist-info}/METADATA +1 -1
- passphera_core-0.5.0.dist-info/RECORD +7 -0
- passphera_core-0.4.0.dist-info/RECORD +0 -7
- {passphera_core-0.4.0.dist-info → passphera_core-0.5.0.dist-info}/WHEEL +0 -0
- {passphera_core-0.4.0.dist-info → passphera_core-0.5.0.dist-info}/top_level.txt +0 -0
passphera_core/generator.py
CHANGED
@@ -9,26 +9,30 @@ class PasswordGenerator:
|
|
9
9
|
"""
|
10
10
|
def __init__(
|
11
11
|
self,
|
12
|
-
text: str = None,
|
13
12
|
shift: int = 3,
|
14
13
|
multiplier: int = 3,
|
15
14
|
key: str = "hill",
|
16
|
-
algorithm: str = 'hill'
|
15
|
+
algorithm: str = 'hill',
|
16
|
+
characters_replacements: dict = None,
|
17
|
+
text: str = None,
|
17
18
|
):
|
18
19
|
"""
|
19
|
-
:param text: plain text to be ciphered
|
20
20
|
:param shift: number of characters to shift each character (default 3)
|
21
21
|
:param multiplier: number of characters to shift each character (default 3)
|
22
22
|
:param key: cipher key string (default "secret")
|
23
23
|
:param algorithm: main cipher algorithm name (default 'playfair')
|
24
|
+
:param characters_replacements: replace characters with the given values (default {})
|
25
|
+
:param text: plain text to be ciphered
|
24
26
|
"""
|
25
|
-
|
26
|
-
|
27
|
+
if characters_replacements is None:
|
28
|
+
characters_replacements = {}
|
27
29
|
self._shift: int = shift
|
28
30
|
self._multiplier: int = multiplier
|
29
31
|
self._key: str = key
|
30
32
|
self._algorithm_name: str = algorithm.lower()
|
31
33
|
self._algorithm = self._set_algorithm()
|
34
|
+
self._characters_replacements: dict = characters_replacements
|
35
|
+
self._text: str = text
|
32
36
|
if text:
|
33
37
|
self._password: str = f"secret{self._text.replace(' ', '')}secret"
|
34
38
|
else:
|
@@ -138,7 +142,7 @@ class PasswordGenerator:
|
|
138
142
|
Eg: ```print(pg.characters_replacements) # {'a': '@1', 'b': '#2'}```
|
139
143
|
:return: dict: The dictionary of the characters replacements
|
140
144
|
"""
|
141
|
-
return self.
|
145
|
+
return self._characters_replacements
|
142
146
|
|
143
147
|
def _set_algorithm(self):
|
144
148
|
"""
|
@@ -171,7 +175,7 @@ class PasswordGenerator:
|
|
171
175
|
:param replacement: The (character|set of characters) to replace the first one
|
172
176
|
:return:
|
173
177
|
"""
|
174
|
-
self.
|
178
|
+
self._characters_replacements[char[0]] = replacement
|
175
179
|
|
176
180
|
def reset_character(self, char: str) -> None:
|
177
181
|
"""
|
@@ -179,8 +183,8 @@ class PasswordGenerator:
|
|
179
183
|
:param char: The character to be reset to its original value
|
180
184
|
:return:
|
181
185
|
"""
|
182
|
-
if char in self.
|
183
|
-
del self.
|
186
|
+
if char in self._characters_replacements:
|
187
|
+
del self._characters_replacements[char]
|
184
188
|
|
185
189
|
def generate_raw_password(self) -> str:
|
186
190
|
"""
|
@@ -203,6 +207,6 @@ class PasswordGenerator:
|
|
203
207
|
for char in self._password:
|
204
208
|
if char in self._text:
|
205
209
|
self._password = self._password.replace(char, char.upper())
|
206
|
-
for char, replacement in self.
|
210
|
+
for char, replacement in self._characters_replacements.items():
|
207
211
|
self._password = self._password.replace(char, replacement)
|
208
212
|
return self._password
|
@@ -0,0 +1,7 @@
|
|
1
|
+
passphera_core/__init__.py,sha256=ND2D_sTQk5mroNRsKm03PXhx0HNf0740hOtZ4_U98OQ,119
|
2
|
+
passphera_core/exceptions.py,sha256=PPZhy05QMVnN3mm6EGj-RgWanMaF3E6aKN4lcpNOJY8,158
|
3
|
+
passphera_core/generator.py,sha256=5jYo38QpFqn7up5pg0dyvJ1VkSvQs3WO5k-xlLVaskg,7317
|
4
|
+
passphera_core-0.5.0.dist-info/METADATA,sha256=CbdDfk0MdYDNe1K03yEpPo6l-xI1tyMuxFy3xGKluCY,628
|
5
|
+
passphera_core-0.5.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
6
|
+
passphera_core-0.5.0.dist-info/top_level.txt,sha256=aDUX2iWGOyfzyf6XakLWTbgeWqNrypMHO074Qratyds,15
|
7
|
+
passphera_core-0.5.0.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
passphera_core/__init__.py,sha256=ND2D_sTQk5mroNRsKm03PXhx0HNf0740hOtZ4_U98OQ,119
|
2
|
-
passphera_core/exceptions.py,sha256=PPZhy05QMVnN3mm6EGj-RgWanMaF3E6aKN4lcpNOJY8,158
|
3
|
-
passphera_core/generator.py,sha256=_OjRbToWw20nOOzBCc7kPg3DwCURK_HoTkI4Dyv7Rls,7036
|
4
|
-
passphera_core-0.4.0.dist-info/METADATA,sha256=9olDGxoeUkzJGImvwSVLwVW7bjUkXBiYwr7fC2vnfQg,628
|
5
|
-
passphera_core-0.4.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
6
|
-
passphera_core-0.4.0.dist-info/top_level.txt,sha256=aDUX2iWGOyfzyf6XakLWTbgeWqNrypMHO074Qratyds,15
|
7
|
-
passphera_core-0.4.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|