-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrot_tools.py
More file actions
49 lines (47 loc) · 1.55 KB
/
Copy pathrot_tools.py
File metadata and controls
49 lines (47 loc) · 1.55 KB
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
import os
import sc_encode
from getkey import getKey
def menu():
global plain_text
while True:
menu = {}
menu['1']="Enter text"
menu['9']="Exit"
if plain_text is not None:
menu['2']="Fixed shift"
menu['3']="Brute force"
menu['4']="Output to file: OFF"
os.system('clear')
options=sorted(menu.keys())
print('{:*^40}'.format('ROT Decoder'),"\n\n")
print("Input text: ",plain_text,"\n\n")
for entry in options:
print(entry, menu[entry])
print("")
selection=getKey()
if selection not in options:
print()
elif selection =='1': #Enter text
plain_text = None
while plain_text is None:
plain_text = input("\nEnter message to encode: ").strip()
elif selection == '2': #Fixed shift
shift = None
while not isinstance(shift, int):
try:
shift=int(input("Shift: "))
except ValueError:
print("Please enter a valid whole number.")
print("\n", sc_encode.decode(plain_text, shift))
getKey()
elif selection == '3': #Brute force
os.system('clear')
sc_encode.brute_force(plain_text)
elif selection == '4': #File out
print("Not implemented yet\nPress any key")
getKey()
elif selection == '9': #Exit
os.system('clear')
break
plain_text = None
menu()