passphera-core 0.25.2__tar.gz → 0.27.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.25.2
3
+ Version: 0.27.0
4
4
  Summary: The core system of passphera project
5
5
  Home-page: https://github.com/passphera/core
6
6
  Author: Fathi Abdelmalek
@@ -61,6 +61,23 @@ class Password:
61
61
  key = derive_key(self.password, self.salt)
62
62
  return Fernet(key).decrypt(self.password.encode()).decode()
63
63
 
64
+ def to_dict(self) -> dict:
65
+ """Convert the Password entity to a dictionary."""
66
+ return {
67
+ "id": self.id,
68
+ "created_at": self.created_at,
69
+ "updated_at": self.updated_at,
70
+ "context": self.context,
71
+ "text": self.text,
72
+ "password": self.password,
73
+ "salt": self.salt,
74
+ }
75
+
76
+ def from_dict(self, data: dict) -> None:
77
+ """Convert a dictionary to a Password entity."""
78
+ for key, value in data.items():
79
+ setattr(self, key, value)
80
+
64
81
 
65
82
  @dataclass
66
83
  class Generator:
@@ -177,3 +194,22 @@ class Generator:
177
194
  password: str = main_algorithm.encrypt(intermediate)
178
195
  password = password.translate(str.maketrans(self.characters_replacements))
179
196
  return ''.join(c.upper() if c in text else c for c in password)
197
+
198
+ def to_dict(self) -> dict:
199
+ """Convert the Generator entity to a dictionary."""
200
+ return {
201
+ "id": self.id,
202
+ "created_at": self.created_at,
203
+ "updated_at": self.updated_at,
204
+ "shift": self.shift,
205
+ "multiplier": self.multiplier,
206
+ "key": self.key,
207
+ "algorithm": self.algorithm,
208
+ "prefix": self.prefix,
209
+ "postfix": self.postfix,
210
+ }
211
+
212
+ def from_dict(self, data: dict) -> None:
213
+ """Convert a dictionary to a Generator entity."""
214
+ for key, value in data.items():
215
+ setattr(self, key, value)
@@ -1,4 +1,5 @@
1
1
  from abc import ABC, abstractmethod
2
+ from uuid import UUID
2
3
 
3
4
  from passphera_core.entities import Password, Generator
4
5
 
@@ -35,7 +36,7 @@ class GeneratorRepository(ABC):
35
36
  pass
36
37
 
37
38
  @abstractmethod
38
- def get(self) -> Generator:
39
+ def get(self, id: UUID) -> Generator:
39
40
  pass
40
41
 
41
42
  @abstractmethod
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: passphera-core
3
- Version: 0.25.2
3
+ Version: 0.27.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 f:
5
5
 
6
6
  setup(
7
7
  name='passphera-core',
8
- version='0.25.2',
8
+ version='0.27.0',
9
9
  author='Fathi Abdelmalek',
10
10
  author_email='abdelmalek.fathi.2001@gmail.com',
11
11
  url='https://github.com/passphera/core',