passphera-core 0.31.0__py3-none-any.whl → 0.32.1__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,5 +1,4 @@
1
1
  from dataclasses import dataclass, field
2
- from datetime import datetime, timezone
3
2
 
4
3
  from cipherspy.cipher import *
5
4
  from cipherspy.exceptions import InvalidAlgorithmException
@@ -12,7 +11,7 @@ _cipher_registry: dict = {
12
11
  'playfair': PlayfairCipherAlgorithm,
13
12
  'hill': HillCipherAlgorithm,
14
13
  }
15
- _default_properties: dict[str, str] = {
14
+ _default_properties: dict[str, object] = {
16
15
  "shift": 3,
17
16
  "multiplier": 3,
18
17
  "key": "hill",
@@ -97,7 +96,6 @@ class Generator:
97
96
  setattr(self, prop, value)
98
97
  if prop == "algorithm":
99
98
  self.get_algorithm()
100
- self.updated_at = datetime.now(timezone.utc)
101
99
 
102
100
  @check_property_name
103
101
  def reset_property(self, prop: str) -> None:
@@ -110,8 +108,7 @@ class Generator:
110
108
  setattr(self, prop, _default_properties[prop])
111
109
  if prop == "algorithm":
112
110
  self.get_algorithm()
113
- self.updated_at = datetime.now(timezone.utc)
114
-
111
+
115
112
  def get_character_replacement(self, character: str) -> str:
116
113
  """
117
114
  Get the replacement string for a given character
@@ -129,7 +126,6 @@ class Generator:
129
126
  :return: None
130
127
  """
131
128
  self.characters_replacements[character[0]] = replacement
132
- self.updated_at = datetime.now(timezone.utc)
133
129
 
134
130
  def reset_character_replacement(self, character: str) -> None:
135
131
  """
@@ -138,7 +134,6 @@ class Generator:
138
134
  :return: None
139
135
  """
140
136
  self.characters_replacements.pop(character, None)
141
- self.updated_at = datetime.now(timezone.utc)
142
137
 
143
138
  def generate_password(self, text: str) -> str:
144
139
  """
@@ -150,7 +145,8 @@ class Generator:
150
145
  secondary_algorithm: AffineCipherAlgorithm = AffineCipherAlgorithm(self.shift, self.multiplier)
151
146
  intermediate: str = secondary_algorithm.encrypt(f"{self.prefix}{text}{self.postfix}")
152
147
  password: str = main_algorithm.encrypt(intermediate)
153
- password = password.translate(str.maketrans(self.characters_replacements))
148
+ for char, repl in self.characters_replacements.items():
149
+ password = password.replace(char, repl)
154
150
  return ''.join(c.upper() if c in text else c for c in password)
155
151
 
156
152
  def to_dict(self) -> dict:
@@ -168,4 +164,5 @@ class Generator:
168
164
  def from_dict(self, data: dict) -> None:
169
165
  """Convert a dictionary to a Generator entity."""
170
166
  for key, value in data.items():
171
- setattr(self, key, value)
167
+ if key in _default_properties or key == "characters_replacements":
168
+ setattr(self, key, value)
@@ -2,8 +2,8 @@ from passphera_core.exceptions import InvalidPropertyNameException
2
2
 
3
3
 
4
4
  def check_property_name(func):
5
- def wrapper(self, prop, value):
5
+ def wrapper(self, prop, *args, **kwargs):
6
6
  if prop not in {"shift", "multiplier", "key", "algorithm", "prefix", "postfix", "character_replacements"}:
7
7
  raise InvalidPropertyNameException(prop)
8
- return func(self, prop, value)
8
+ return func(self, prop, *args, **kwargs)
9
9
  return wrapper
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: passphera-core
3
- Version: 0.31.0
3
+ Version: 0.32.1
4
4
  Summary: The core of passphera project
5
5
  Home-page: https://github.com/passphera/core
6
6
  Author: Fathi Abdelmalek
@@ -0,0 +1,8 @@
1
+ passphera_core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ passphera_core/entities.py,sha256=LzYn3f1Ul6J2eqNRqAtpVz2H6imFEsZ1cmW4QOlVS5s,6846
3
+ passphera_core/exceptions.py,sha256=nb0iWLaFpFHEUjCa5dQ8UnIn3tZs8gN5dy2URgqJf0g,211
4
+ passphera_core/utilities.py,sha256=2cu6qWu3iseCejStxk4vD35bhQfgvb1WWx0DzXEMp_w,382
5
+ passphera_core-0.32.1.dist-info/METADATA,sha256=0pfzO3UwCK7rBm3YbJ7CYqFfk3AxealVjfJKu4FzklY,851
6
+ passphera_core-0.32.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
+ passphera_core-0.32.1.dist-info/top_level.txt,sha256=aDUX2iWGOyfzyf6XakLWTbgeWqNrypMHO074Qratyds,15
8
+ passphera_core-0.32.1.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- passphera_core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- passphera_core/entities.py,sha256=RXoSnJgLpij3zYSWN9JeybiujTz1IZgHIZh3MxW3Z58,6987
3
- passphera_core/exceptions.py,sha256=nb0iWLaFpFHEUjCa5dQ8UnIn3tZs8gN5dy2URgqJf0g,211
4
- passphera_core/utilities.py,sha256=O15lTSzT-kNUnPkx9Eufc_qET7uK-9cccPKzx2gHz0s,362
5
- passphera_core-0.31.0.dist-info/METADATA,sha256=EFYOC1RNysf0UPMaYqjzNZBXdOjuHQz0b08_iLA9vVs,851
6
- passphera_core-0.31.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
- passphera_core-0.31.0.dist-info/top_level.txt,sha256=aDUX2iWGOyfzyf6XakLWTbgeWqNrypMHO074Qratyds,15
8
- passphera_core-0.31.0.dist-info/RECORD,,