-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
143 lines (137 loc) · 3.77 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
from cryptography_methods.SHIFT_CIPHER import Shift_Cipher
from cryptography_methods.AFFINE_CIPHER import Affine_Cipher
from cryptography_methods.SUBSTITUTION_CIPHER import Substitution_Cipher
from cryptography_methods.VIGENERE_CIPHER import Vigenere_Cipher
import os
class L:
def __init__(self):
self.LANGUAGE = "abcdefghijklmnopqrstuvwxyz"
SPEED = 1.5
DELAY = 0.1
def print_logo():
print("""
____ _ _
/ ___|_ __ _ _ _ __ | |_ ___ __ _ _ __ __ _ _ __ | |__ _ _
| | | '__| | | | '_ \| __/ _ \ / _` | '__/ _` | '_ \| '_ \| | | |
| |___| | | |_| | |_) | || (_) | (_| | | | (_| | |_) | | | | |_| |
\____|_| \__, | .__/ \__\___/ \__, |_| \__,_| .__/|_| |_|\__, |
|___/|_| |___/ |_| |___/
""")
def menu():
os.system("cls")
print_logo()
print("\n[1] Do cryptography")
print("[2] Solve a cryptography")
print("[3] Settings")
print("[4] Exit")
while(1):
mode = int(input(">>> "))
if(mode == 1):
cryptosystem()
break
elif(mode == 2):
exit()
break
elif(mode == 3):
settings()
break
elif(mode == 4):
exit()
break
else:
print("invalid choose")
def cryptosystem():
os.system("cls")
print_logo()
print("\n[1] Shift cipher")
print("[2] Substitution cipher")
print("[3] Affine cipher")
print("[4] Vigenere cipher")
print("[5] Menu")
print("[6] exit")
while(1):
mode = int(input(">>> "))
if(mode == 1):
sc = Shift_Cipher(SPEED, lg.LANGUAGE)
sc.do()
cryptosystem()
elif(mode == 2):
sc = Substitution_Cipher(SPEED, lg.LANGUAGE)
sc.do()
cryptosystem()
elif(mode == 3):
ac = Affine_Cipher(SPEED, lg.LANGUAGE)
ac.do()
cryptosystem()
elif(mode == 4):
vc = Vigenere_Cipher(SPEED, lg.LANGUAGE)
vc.do()
cryptosystem()
elif(mode == 5):
menu()
elif(mode == 6):
exit()
break
else:
print("invalid choose")
def settings():
os.system("cls")
print_logo()
print("\n[1] Delay")
print("[2] Language")
print("[3] Menu")
print("[4] exit")
while(1):
mode = int(input(">>> "))
if(mode == 1):
SPEED = float(input("Delay (default delay is 1.5): "))
settings()
break
elif(mode == 2):
languages()
break
elif(mode == 3):
menu()
elif(mode == 4):
exit()
break
else:
print("invalid choose")
def languages():
os.system("cls")
print_logo()
print("\n[1] Add to default language")
print("[2] Set language")
print("[3] Persian")
print("[4] Settings")
print("[5] Menu")
print("[6] exit")
while(1):
mode = int(input(">>> "))
if(mode == 1):
print("Alphabet is "+lg.LANGUAGE)
LL = input("Characters to add without space: ")
lg.LANGUAGE = lg.LANGUAGE + LL
settings()
break
elif(mode == 2):
lg.LANGUAGE = input("Set Language: ")
languages()
break
elif(mode == 3):
lg.LANGUAGE = "ابپتثجچحخدذرزژسشصضطظعغفقکگلمنوهي"
languages()
break
elif(mode == 5):
menu()
break
elif(mode == 4):
settings()
break
elif(mode == 6):
exit()
break
else:
print("invalid choose")
lg = L()
menu()