passphera-core 0.3.4__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.
@@ -1,2 +1,2 @@
1
- from .generator import PasswordGenerator
2
- from .exceptions import InvalidAlgorithmException
1
+ from passphera_core.generator import PasswordGenerator
2
+ from passphera_core.exceptions import InvalidAlgorithmException
@@ -1,3 +1,3 @@
1
1
  class InvalidAlgorithmException(Exception):
2
2
  def __init__(self, algorithm: str) -> None:
3
- super().__init__(f"Invalid algorithm name {algorithm}")
3
+ super().__init__(f"Invalid algorithm name [{algorithm}]")
@@ -9,29 +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
- key_str: str = "secret",
16
- key_iter: iter = (9, 4, 5, 7),
17
- algorithm: str = 'playfair'
14
+ key: str = "hill",
15
+ algorithm: str = 'hill',
16
+ characters_replacements: dict = None,
17
+ text: str = None,
18
18
  ):
19
19
  """
20
- :param text: plain text to be ciphered
21
20
  :param shift: number of characters to shift each character (default 3)
22
21
  :param multiplier: number of characters to shift each character (default 3)
23
- :param key_str: cipher key string (default "secret")
24
- :param key_iter: cipher key matrix (default (9, 4, 5, 7))
22
+ :param key: cipher key string (default "secret")
25
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
26
26
  """
27
- self._chars_replacements: dict = {}
28
- self._text: str = text
27
+ if characters_replacements is None:
28
+ characters_replacements = {}
29
29
  self._shift: int = shift
30
30
  self._multiplier: int = multiplier
31
- self._key_str: str = key_str
32
- self._key_iter: iter = key_iter
31
+ self._key: str = key
33
32
  self._algorithm_name: str = algorithm.lower()
34
33
  self._algorithm = self._set_algorithm()
34
+ self._characters_replacements: dict = characters_replacements
35
+ self._text: str = text
35
36
  if text:
36
37
  self._password: str = f"secret{self._text.replace(' ', '')}secret"
37
38
  else:
@@ -96,42 +97,23 @@ class PasswordGenerator:
96
97
  self._multiplier = multiplier
97
98
 
98
99
  @property
99
- def key_str(self) -> str:
100
+ def key(self) -> str:
100
101
  """
101
102
  Returns the key string for the cipher algorithm
102
103
  Eg: ```key_str = pg.key_str```
103
104
  :return: str: The key string for the cipher algorithm
104
105
  """
105
- return self._key_str
106
+ return self._key
106
107
 
107
- @key_str.setter
108
- def key_str(self, key_str: str) -> None:
108
+ @key.setter
109
+ def key(self, key: str) -> None:
109
110
  """
110
111
  Sets the key string for the cipher algorithm
111
- Eg: ```pg.key_str = 'secret key'```
112
- :param key_str: The key string for the cipher algorithm
113
- :return:
114
- """
115
- self._key_str = key_str
116
-
117
- @property
118
- def key_iter(self) -> iter:
119
- """
120
- Returns the key matrix for the cipher algorithm
121
- Eg: ```key_iter = pg.key_iter```
122
- :return: iter: The key matrix for the cipher algorithm
123
- """
124
- return self._key_iter
125
-
126
- @key_iter.setter
127
- def key_iter(self, key_iter: iter) -> None:
128
- """
129
- Sets the key matrix for the cipher algorithm
130
- Eg: ```pg.key_iter = (9, 5, 2, 4)```
131
- :param key_iter: The key matrix for the cipher algorithm
112
+ Eg: ```pg.key = 'secret key'```
113
+ :param key: The key string for the cipher algorithm
132
114
  :return:
133
115
  """
134
- self._key_iter = key_iter
116
+ self._key = key
135
117
 
136
118
  @property
137
119
  def algorithm(self) -> str:
@@ -160,7 +142,7 @@ class PasswordGenerator:
160
142
  Eg: ```print(pg.characters_replacements) # {'a': '@1', 'b': '#2'}```
161
143
  :return: dict: The dictionary of the characters replacements
162
144
  """
163
- return self._chars_replacements
145
+ return self._characters_replacements
164
146
 
165
147
  def _set_algorithm(self):
166
148
  """
@@ -173,9 +155,9 @@ class PasswordGenerator:
173
155
  case 'affine':
174
156
  return AffineCipher(self._multiplier, self._shift)
175
157
  case 'playfair':
176
- return PlayfairCipher(self._key_str)
158
+ return PlayfairCipher(self._key)
177
159
  case 'hill':
178
- return HillCipher(self._key_iter)
160
+ return HillCipher(self._key)
179
161
  case _:
180
162
  raise InvalidAlgorithmException(self._algorithm_name)
181
163
 
@@ -193,7 +175,7 @@ class PasswordGenerator:
193
175
  :param replacement: The (character|set of characters) to replace the first one
194
176
  :return:
195
177
  """
196
- self._chars_replacements[char[0]] = replacement
178
+ self._characters_replacements[char[0]] = replacement
197
179
 
198
180
  def reset_character(self, char: str) -> None:
199
181
  """
@@ -201,8 +183,8 @@ class PasswordGenerator:
201
183
  :param char: The character to be reset to its original value
202
184
  :return:
203
185
  """
204
- if char in self._chars_replacements:
205
- del self._chars_replacements[char]
186
+ if char in self._characters_replacements:
187
+ del self._characters_replacements[char]
206
188
 
207
189
  def generate_raw_password(self) -> str:
208
190
  """
@@ -225,6 +207,6 @@ class PasswordGenerator:
225
207
  for char in self._password:
226
208
  if char in self._text:
227
209
  self._password = self._password.replace(char, char.upper())
228
- for char, replacement in self._chars_replacements.items():
210
+ for char, replacement in self._characters_replacements.items():
229
211
  self._password = self._password.replace(char, replacement)
230
212
  return self._password
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: passphera-core
3
- Version: 0.3.4
3
+ Version: 0.5.0
4
4
  Summary: The core system of passphera project
5
5
  Home-page: https://github.com/passphera/core
6
6
  Author: Fathi Abdelmalek
@@ -14,6 +14,6 @@ Classifier: Topic :: Security
14
14
  Classifier: Topic :: Security :: Cryptography
15
15
  Description-Content-Type: text/markdown
16
16
 
17
- # passphera-cre
17
+ # passphera-core
18
18
 
19
19
  The core system of passphera project
@@ -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=zDJS1wcjyfEwO4YifFwghhWE3fM2pZNqodx8B4PkGDA,91
2
- passphera_core/exceptions.py,sha256=M0wVUORrukx2wIkHAz42Sz4BMMY8JssZp7iuHaEjARc,155
3
- passphera_core/generator.py,sha256=9Iz9ZCwYk4T0syefhErwWN5TentL2KGR_y7FjwB1l-A,7821
4
- passphera_core-0.3.4.dist-info/METADATA,sha256=5GV9eRooBYFEtkMFrJR3mYFPenHct_eP4xJ8919D_so,627
5
- passphera_core-0.3.4.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
6
- passphera_core-0.3.4.dist-info/top_level.txt,sha256=aDUX2iWGOyfzyf6XakLWTbgeWqNrypMHO074Qratyds,15
7
- passphera_core-0.3.4.dist-info/RECORD,,