passphera-core 0.3.3__tar.gz → 0.4.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.3.3
3
+ Version: 0.4.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
@@ -1,3 +1,3 @@
1
- # passphera-cre
1
+ # passphera-core
2
2
 
3
3
  The core system of passphera project
@@ -0,0 +1,2 @@
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}]")
@@ -12,24 +12,21 @@ class PasswordGenerator:
12
12
  text: str = None,
13
13
  shift: int = 3,
14
14
  multiplier: int = 3,
15
- key_str: str = "secret",
16
- key_iter: iter = (9, 4, 5, 7),
17
- algorithm: str = 'playfair'
15
+ key: str = "hill",
16
+ algorithm: str = 'hill'
18
17
  ):
19
18
  """
20
19
  :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')
26
24
  """
27
25
  self._chars_replacements: dict = {}
28
26
  self._text: str = text
29
27
  self._shift: int = shift
30
28
  self._multiplier: int = multiplier
31
- self._key_str: str = key_str
32
- self._key_iter: iter = key_iter
29
+ self._key: str = key
33
30
  self._algorithm_name: str = algorithm.lower()
34
31
  self._algorithm = self._set_algorithm()
35
32
  if text:
@@ -96,42 +93,23 @@ class PasswordGenerator:
96
93
  self._multiplier = multiplier
97
94
 
98
95
  @property
99
- def key_str(self) -> str:
96
+ def key(self) -> str:
100
97
  """
101
98
  Returns the key string for the cipher algorithm
102
99
  Eg: ```key_str = pg.key_str```
103
100
  :return: str: The key string for the cipher algorithm
104
101
  """
105
- return self._key_str
102
+ return self._key
106
103
 
107
- @key_str.setter
108
- def key_str(self, key_str: str) -> None:
104
+ @key.setter
105
+ def key(self, key: str) -> None:
109
106
  """
110
107
  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
108
+ Eg: ```pg.key = 'secret key'```
109
+ :param key: The key string for the cipher algorithm
113
110
  :return:
114
111
  """
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
132
- :return:
133
- """
134
- self._key_iter = key_iter
112
+ self._key = key
135
113
 
136
114
  @property
137
115
  def algorithm(self) -> str:
@@ -173,9 +151,9 @@ class PasswordGenerator:
173
151
  case 'affine':
174
152
  return AffineCipher(self._multiplier, self._shift)
175
153
  case 'playfair':
176
- return PlayfairCipher(self._key_str)
154
+ return PlayfairCipher(self._key)
177
155
  case 'hill':
178
- return HillCipher(self._key_iter)
156
+ return HillCipher(self._key)
179
157
  case _:
180
158
  raise InvalidAlgorithmException(self._algorithm_name)
181
159
 
@@ -222,9 +200,9 @@ class PasswordGenerator:
222
200
  self._password = self.generate_raw_password()
223
201
  self._algorithm_name = old_algorithm
224
202
  self._password = self.generate_raw_password()
225
- for char, replacement in self._chars_replacements.items():
226
- self._password = self._password.replace(char, replacement)
227
203
  for char in self._password:
228
204
  if char in self._text:
229
205
  self._password = self._password.replace(char, char.upper())
206
+ for char, replacement in self._chars_replacements.items():
207
+ self._password = self._password.replace(char, replacement)
230
208
  return self._password
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: passphera-core
3
- Version: 0.3.3
3
+ Version: 0.4.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
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setup(
7
7
  name='passphera-core',
8
- version='0.3.3',
8
+ version='0.4.0',
9
9
  author='Fathi Abdelmalek',
10
10
  author_email='abdelmalek.fathi.2001@gmail.com',
11
11
  url='https://github.com/passphera/core',
@@ -1,2 +0,0 @@
1
- from .generator import PasswordGenerator
2
- from .exceptions import InvalidAlgorithmException
File without changes