passphera-core 0.30.0__tar.gz → 0.30.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: passphera-core
3
- Version: 0.30.0
3
+ Version: 0.30.2
4
4
  Summary: The core system of passphera project
5
5
  Home-page: https://github.com/passphera/core
6
6
  Author: Fathi Abdelmalek
@@ -97,9 +97,19 @@ class Generator:
97
97
  Get the primary algorithm used to cipher the password
98
98
  :return: BaseCipherAlgorithm: The primary algorithm used for the cipher
99
99
  """
100
- if self.algorithm.lower() not in _cipher_registry:
100
+ algo_name = self.algorithm.lower()
101
+ if algo_name not in _cipher_registry:
101
102
  raise InvalidAlgorithmException(self.algorithm)
102
- return _cipher_registry[self.algorithm.lower()]
103
+ AlgoClass = _cipher_registry[algo_name]
104
+ if algo_name == "caesar":
105
+ return AlgoClass(self.shift)
106
+ elif algo_name == "affine":
107
+ return AlgoClass(self.shift, self.multiplier)
108
+ elif algo_name == "playfair":
109
+ return AlgoClass(self.key)
110
+ elif algo_name == "hill":
111
+ return AlgoClass(self.key)
112
+ raise InvalidAlgorithmException(self.algorithm)
103
113
 
104
114
  def get_properties(self) -> dict:
105
115
  """
@@ -131,7 +141,7 @@ class Generator:
131
141
  :raises ValueError: If the property name is not one of the allowed properties
132
142
  :return: None
133
143
  """
134
- if prop not in {"shift", "multiplier", "key", "algorithm", "prefix", "postfix"}:
144
+ if prop not in {"id", "created_at", "updated_at", "shift", "multiplier", "key", "algorithm", "prefix", "postfix"}:
135
145
  raise InvalidPropertyNameException(prop)
136
146
  if prop in ["shift", "multiplier"]:
137
147
  value = int(value)
@@ -147,7 +157,7 @@ class Generator:
147
157
  :raises ValueError: If the property name is not one of the allowed properties
148
158
  :return: None
149
159
  """
150
- if prop not in {"shift", "multiplier", "key", "algorithm", "prefix", "postfix"}:
160
+ if prop not in {"id", "created_at", "updated_at", "shift", "multiplier", "key", "algorithm", "prefix", "postfix"}:
151
161
  raise InvalidPropertyNameException(prop)
152
162
  setattr(self, prop, _default_properties[prop])
153
163
  if prop == "algorithm":
@@ -191,7 +201,7 @@ class Generator:
191
201
  main_algorithm: BaseCipherAlgorithm = self.get_algorithm()
192
202
  secondary_algorithm: AffineCipherAlgorithm = AffineCipherAlgorithm(self.shift, self.multiplier)
193
203
  intermediate: str = secondary_algorithm.encrypt(f"{self.prefix}{text}{self.postfix}")
194
- password: str = main_algorithm.encrypt(intermediate)
204
+ password: str = main_algorithm.encrypt(f"{self.prefix}{intermediate}{self.postfix}")
195
205
  password = password.translate(str.maketrans(self.characters_replacements))
196
206
  return ''.join(c.upper() if c in text else c for c in password)
197
207
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: passphera-core
3
- Version: 0.30.0
3
+ Version: 0.30.2
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 f:
5
5
 
6
6
  setup(
7
7
  name='passphera-core',
8
- version='0.30.0',
8
+ version='0.30.2',
9
9
  author='Fathi Abdelmalek',
10
10
  author_email='abdelmalek.fathi.2001@gmail.com',
11
11
  url='https://github.com/passphera/core',