passphera-core 0.31.0__tar.gz → 0.32.0__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.31.0
3
+ Version: 0.32.0
4
4
  Summary: The core of passphera project
5
5
  Home-page: https://github.com/passphera/core
6
6
  Author: Fathi Abdelmalek
@@ -12,7 +12,7 @@ _cipher_registry: dict = {
12
12
  'playfair': PlayfairCipherAlgorithm,
13
13
  'hill': HillCipherAlgorithm,
14
14
  }
15
- _default_properties: dict[str, str] = {
15
+ _default_properties: dict[str, object] = {
16
16
  "shift": 3,
17
17
  "multiplier": 3,
18
18
  "key": "hill",
@@ -97,7 +97,6 @@ class Generator:
97
97
  setattr(self, prop, value)
98
98
  if prop == "algorithm":
99
99
  self.get_algorithm()
100
- self.updated_at = datetime.now(timezone.utc)
101
100
 
102
101
  @check_property_name
103
102
  def reset_property(self, prop: str) -> None:
@@ -110,7 +109,6 @@ class Generator:
110
109
  setattr(self, prop, _default_properties[prop])
111
110
  if prop == "algorithm":
112
111
  self.get_algorithm()
113
- self.updated_at = datetime.now(timezone.utc)
114
112
 
115
113
  def get_character_replacement(self, character: str) -> str:
116
114
  """
@@ -129,7 +127,6 @@ class Generator:
129
127
  :return: None
130
128
  """
131
129
  self.characters_replacements[character[0]] = replacement
132
- self.updated_at = datetime.now(timezone.utc)
133
130
 
134
131
  def reset_character_replacement(self, character: str) -> None:
135
132
  """
@@ -138,7 +135,6 @@ class Generator:
138
135
  :return: None
139
136
  """
140
137
  self.characters_replacements.pop(character, None)
141
- self.updated_at = datetime.now(timezone.utc)
142
138
 
143
139
  def generate_password(self, text: str) -> str:
144
140
  """
@@ -150,7 +146,8 @@ class Generator:
150
146
  secondary_algorithm: AffineCipherAlgorithm = AffineCipherAlgorithm(self.shift, self.multiplier)
151
147
  intermediate: str = secondary_algorithm.encrypt(f"{self.prefix}{text}{self.postfix}")
152
148
  password: str = main_algorithm.encrypt(intermediate)
153
- password = password.translate(str.maketrans(self.characters_replacements))
149
+ for char, repl in self.characters_replacements.items():
150
+ password = password.replace(char, repl)
154
151
  return ''.join(c.upper() if c in text else c for c in password)
155
152
 
156
153
  def to_dict(self) -> dict:
@@ -168,4 +165,5 @@ class Generator:
168
165
  def from_dict(self, data: dict) -> None:
169
166
  """Convert a dictionary to a Generator entity."""
170
167
  for key, value in data.items():
171
- setattr(self, key, value)
168
+ if key in _default_properties or key == "characters_replacements":
169
+ 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.0
4
4
  Summary: The core 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.31.0',
8
+ version='0.32.0',
9
9
  author='Fathi Abdelmalek',
10
10
  author_email='passphera@imfathi.com',
11
11
  url='https://github.com/passphera/core',