passphera-core 0.1.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.
- passphera-core-0.1.0/PKG-INFO +19 -0
- passphera-core-0.1.0/README.md +3 -0
- passphera-core-0.1.0/passphera_core/__init__.py +117 -0
- passphera-core-0.1.0/passphera_core.egg-info/PKG-INFO +19 -0
- passphera-core-0.1.0/passphera_core.egg-info/SOURCES.txt +7 -0
- passphera-core-0.1.0/passphera_core.egg-info/dependency_links.txt +1 -0
- passphera-core-0.1.0/passphera_core.egg-info/top_level.txt +1 -0
- passphera-core-0.1.0/setup.cfg +4 -0
- passphera-core-0.1.0/setup.py +25 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: passphera-core
|
3
|
+
Version: 0.1.0
|
4
|
+
Summary: The core system of passphera project
|
5
|
+
Home-page: https://github.com/passphera/core
|
6
|
+
Author: Fathi Abdelmalek
|
7
|
+
Author-email: abdelmalek.fathi.2001@gmail.com
|
8
|
+
Classifier: Development Status :: 1 - Planning
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
10
|
+
Classifier: Operating System :: OS Independent
|
11
|
+
Classifier: Programming Language :: Python
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
13
|
+
Classifier: Topic :: Security
|
14
|
+
Classifier: Topic :: Security :: Cryptography
|
15
|
+
Description-Content-Type: text/markdown
|
16
|
+
|
17
|
+
# passphera-cre
|
18
|
+
|
19
|
+
The core system of passphera project
|
@@ -0,0 +1,117 @@
|
|
1
|
+
from cipherspy.cipher import *
|
2
|
+
|
3
|
+
|
4
|
+
class InvalidAlgorithmException(Exception):
|
5
|
+
def __init__(self, algorithm: str) -> None:
|
6
|
+
super().__init__(f"Invalid algorithm name {algorithm}")
|
7
|
+
|
8
|
+
|
9
|
+
class PasswordGenerator:
|
10
|
+
def __init__(
|
11
|
+
self,
|
12
|
+
text: str = None,
|
13
|
+
shift: int = 3,
|
14
|
+
multiplier: int = 3,
|
15
|
+
key_str: str = "secret",
|
16
|
+
key_iter: iter = (9, 4, 5, 7),
|
17
|
+
algorithm: str = 'playfair'
|
18
|
+
):
|
19
|
+
self._char_replacements: dict = {}
|
20
|
+
self._text: str = text
|
21
|
+
self._shift: int = shift
|
22
|
+
self._multiplier: int = multiplier
|
23
|
+
self._key_str: str = key_str
|
24
|
+
self._key_iter: iter = key_iter
|
25
|
+
self._algorithm_name: str = algorithm.lower()
|
26
|
+
self._algorithm = self._set_algorithm()
|
27
|
+
|
28
|
+
@property
|
29
|
+
def text(self) -> str:
|
30
|
+
return self._text
|
31
|
+
|
32
|
+
@text.setter
|
33
|
+
def text(self, text: str) -> None:
|
34
|
+
self._text = text
|
35
|
+
|
36
|
+
@property
|
37
|
+
def shift(self) -> int:
|
38
|
+
return self._shift
|
39
|
+
|
40
|
+
@shift.setter
|
41
|
+
def shift(self, shift: int) -> None:
|
42
|
+
self._shift = shift
|
43
|
+
|
44
|
+
@property
|
45
|
+
def multiplier(self) -> int:
|
46
|
+
return self._multiplier
|
47
|
+
|
48
|
+
@multiplier.setter
|
49
|
+
def multiplier(self, multiplier: int) -> None:
|
50
|
+
self._multiplier = multiplier
|
51
|
+
|
52
|
+
@property
|
53
|
+
def key_str(self) -> str:
|
54
|
+
return self._key_str
|
55
|
+
|
56
|
+
@key_str.setter
|
57
|
+
def key_str(self, key_str: str) -> None:
|
58
|
+
self._key_str = key_str
|
59
|
+
|
60
|
+
@property
|
61
|
+
def key_iter(self) -> iter:
|
62
|
+
return self._key_iter
|
63
|
+
|
64
|
+
@key_iter.setter
|
65
|
+
def key_iter(self, key_iter: iter) -> None:
|
66
|
+
self._key_iter = key_iter
|
67
|
+
|
68
|
+
@property
|
69
|
+
def algorithm(self) -> str:
|
70
|
+
return self._algorithm_name
|
71
|
+
|
72
|
+
@algorithm.setter
|
73
|
+
def algorithm(self, algorithm: str) -> None:
|
74
|
+
self._algorithm_name = algorithm.lower()
|
75
|
+
self._algorithm = self._set_algorithm()
|
76
|
+
|
77
|
+
@property
|
78
|
+
def character_replacements(self) -> dict:
|
79
|
+
return self._char_replacements
|
80
|
+
|
81
|
+
def _set_algorithm(self):
|
82
|
+
match self._algorithm_name:
|
83
|
+
case 'caesar':
|
84
|
+
return CaesarCipher(self._shift)
|
85
|
+
case 'affine':
|
86
|
+
return AffineCipher(self._multiplier, self._shift)
|
87
|
+
case 'playfair':
|
88
|
+
return PlayfairCipher(self._key_str)
|
89
|
+
case 'hill':
|
90
|
+
return HillCipher(self._key_iter)
|
91
|
+
case _:
|
92
|
+
raise InvalidAlgorithmException(self._algorithm_name)
|
93
|
+
|
94
|
+
def _update_algorithm_properties(self) -> None:
|
95
|
+
self._algorithm = self._set_algorithm()
|
96
|
+
|
97
|
+
def _custom_cipher(self, password: str) -> str:
|
98
|
+
for char, replacement in self._char_replacements.items():
|
99
|
+
password = password.replace(char, replacement)
|
100
|
+
for i in range(len(password)):
|
101
|
+
if password[i] in self._text:
|
102
|
+
password = password.replace(password[i], password[i].upper())
|
103
|
+
return password
|
104
|
+
|
105
|
+
def replace_character(self, char: str, replacement: str) -> None:
|
106
|
+
self._char_replacements[char[0]] = replacement
|
107
|
+
|
108
|
+
def reset_character(self, char: str) -> None:
|
109
|
+
if char in self._char_replacements:
|
110
|
+
del self._char_replacements[char]
|
111
|
+
|
112
|
+
def generate_raw_password(self) -> str:
|
113
|
+
self._update_algorithm_properties()
|
114
|
+
return self._algorithm.encrypt(self._text)
|
115
|
+
|
116
|
+
def generate_password(self) -> str:
|
117
|
+
return self._custom_cipher(self.generate_raw_password())
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: passphera-core
|
3
|
+
Version: 0.1.0
|
4
|
+
Summary: The core system of passphera project
|
5
|
+
Home-page: https://github.com/passphera/core
|
6
|
+
Author: Fathi Abdelmalek
|
7
|
+
Author-email: abdelmalek.fathi.2001@gmail.com
|
8
|
+
Classifier: Development Status :: 1 - Planning
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
10
|
+
Classifier: Operating System :: OS Independent
|
11
|
+
Classifier: Programming Language :: Python
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
13
|
+
Classifier: Topic :: Security
|
14
|
+
Classifier: Topic :: Security :: Cryptography
|
15
|
+
Description-Content-Type: text/markdown
|
16
|
+
|
17
|
+
# passphera-cre
|
18
|
+
|
19
|
+
The core system of passphera project
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
passphera_core
|
@@ -0,0 +1,25 @@
|
|
1
|
+
from setuptools import setup
|
2
|
+
|
3
|
+
with open("README.md", "r") as fh:
|
4
|
+
long_description = fh.read()
|
5
|
+
|
6
|
+
setup(
|
7
|
+
name='passphera-core',
|
8
|
+
version='0.1.0',
|
9
|
+
author='Fathi Abdelmalek',
|
10
|
+
author_email='abdelmalek.fathi.2001@gmail.com',
|
11
|
+
url='https://github.com/passphera/core',
|
12
|
+
description='The core system of passphera project',
|
13
|
+
long_description=long_description,
|
14
|
+
long_description_content_type="text/markdown",
|
15
|
+
packages=['passphera_core'],
|
16
|
+
classifiers=[
|
17
|
+
"Development Status :: 1 - Planning",
|
18
|
+
"License :: OSI Approved :: MIT License",
|
19
|
+
"Operating System :: OS Independent",
|
20
|
+
"Programming Language :: Python",
|
21
|
+
"Programming Language :: Python :: 3",
|
22
|
+
"Topic :: Security",
|
23
|
+
"Topic :: Security :: Cryptography",
|
24
|
+
]
|
25
|
+
)
|