-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
72 lines (58 loc) · 1.6 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
import getopt, sys
import curses, ui
from cryptosystems import rsa
#/ - - - - - - - - - - - - - - - - - - - - UI functions- - - - - - - - - - - - - - - - - - - - -
def usage():
print("\tScript to present and play cryptosystems.\n--p0: \'n\': set first prime to p0, otherwise 19.\n")
def get_options(job):
if len(job)<1: job.append(0)
if len(job)<2: job.append(19)
try:
opts, args = getopt.getopt(sys.argv[1:], "h", ["help", "p0="])
except getopt.GetoptError:
return 0
job[0] = 1
for opt, arg in opts:
if opt in ("--p0"):
job[0] = 1
try:
job[1]=int(arg)
except Exception:
print(" Wrong argument after p0. Please type the decimal number!")
job[0] = 0
if job[0] != 0 and job[1] > 20000:
print(" The value of p0 is too big; upper limit is 20000.")
job[0] = 0
elif opt in ("-h", "--help"):
usage()
job[0] = 0
return job[0]
# end
#/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def main(stdscr, job):
if not job[0]:
return
stdscr = curses.initscr()
curses.noecho()
curses.cbreak()
stdscr.keypad(True)
#run = True
#menu = ["RSA cryptosystem", ...]
#selected = 0
#while run:
#ui.print_menu(stdscr, menu, [], selected, row_begin)
#(task, selected, n) = ui.input_select(stdscr, [], selected)
# if task == ord('\n') and selected == 0:
# elif task == ord('\n') and selected == 1:
# elif task == ord('\n') and selected == 2:
rsa.run(stdscr, job)
# else:
curses.nocbreak()
stdscr.keypad(False)
curses.echo()
curses.endwin()
#
if __name__ == '__main__':
job = [0,19]
get_options(job)
curses.wrapper(main, job)