-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
64 lines (47 loc) · 1.58 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
'''
Ciphers - Python
parosomniac
24 November 2024
A program that allows users to
encode and decode messages using
4 of the most common ciphers
'''
import ciphers
def switch_mode():
user_input = -1
while not(user_input == "1" or user_input == "2"):
user_input = input("Would you like to encode(1) or " +
"decode(2) a message?")
return int(user_input)
def switch_menu(user_input):
if user_input == -1:
return
mode = switch_mode()
message = input("Enter your message: ")
# Atbash cipher
if user_input == 1:
print(ciphers.atbashEncodeDecode(message))
# Caesar cipher
elif user_input == 2:
print(ciphers.caesarEncodeDecode(message, mode, ciphers.getShift()))
# Affine cipher
elif user_input == 3:
print(ciphers.affineEncodeDecode(message, mode, ciphers.getSlopeIntercept()))
# Viginere cipher
elif user_input == 4:
print(ciphers.viginereEncodeDecode(message, mode, ciphers.getKey()))
def main():
user_input = 0
while not (user_input) == -1:
try:
user_input = int(input("\nSelect from the cipher options below or enter -1 to quit.\n"
+ "1) Atbash Cipher\n" +
"2) Caesar cipher\n" +
"3) Affine cipher\n" +
"4) Viginere cipher\n"
"-1) Quit\n"))
switch_menu(user_input)
except:
print("Please enter an integer from the menu options given. ")
print("Program ended.")
main()