passphera-core 0.4.0__tar.gz → 0.5.0__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: passphera-core
3
- Version: 0.4.0
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
@@ -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
- self._chars_replacements: dict = {}
26
- self._text: str = text
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._chars_replacements
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._chars_replacements[char[0]] = replacement
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._chars_replacements:
183
- del self._chars_replacements[char]
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._chars_replacements.items():
210
+ for char, replacement in self._characters_replacements.items():
207
211
  self._password = self._password.replace(char, replacement)
208
212
  return self._password
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: passphera-core
3
- Version: 0.4.0
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
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setup(
7
7
  name='passphera-core',
8
- version='0.4.0',
8
+ version='0.5.0',
9
9
  author='Fathi Abdelmalek',
10
10
  author_email='abdelmalek.fathi.2001@gmail.com',
11
11
  url='https://github.com/passphera/core',
File without changes
File without changes