-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.rb
104 lines (92 loc) · 2.88 KB
/
menu.rb
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
require 'tty-prompt'
require 'tty-command'
# create a tty prompt
prompt = TTY::Prompt.new
menu_options = [
{ name: 'pub: RSA-2048 sym: AES-256, mode: CBC', value: 'aes_rsa'},
{ name: 'pub: RSA-2048 sym: 3DES, mode: ECB', value: '3des_rsa'},
{ name: 'pub: ECC-prime256v1 sym: AES-256, mode: CBC', value: 'ecc_aes' },
{ name: 'pub: ECC-prime256v1 sym: Blowfish, mode: CBC', value: 'ecc_blowfish'},
{ name: 'quit', value: 'exit'}
]
selected_option = prompt.select('Choose an option:', menu_options)
case selected_option
when 'aes_rsa'
puts "Enter 'e' for encryption or 'd' for decryption: "
choice = gets.chomp.downcase
case choice
when 'e'
puts "Enter the english plaintext: "
plaintext = gets.chomp
prompt.keypress("Press any key to continue...")
cmd = TTY::Command.new
cmd.run("ruby aes_rsa.rb #{plaintext}")
when 'd'
puts "Enter the encoded ciphertext: "
ciphertext = gets.chomp
prompt.keypress("Press any key to continue...")
cmd = TTY::Command.new
cmd.run("ruby aes_rsa.rb #{ciphertext}")
else
puts "The choice was invalid. Enter 'e' or 'd' "
end
when '3des_rsa'
puts "Enter 'e' for encryption or 'd' for decryption: "
choice = gets.chomp.downcase
case choice
when 'e'
puts "Enter the english plaintext: "
plaintext = gets.chomp
prompt.keypress("Press any key to continue...")
cmd = TTY::Command.new
cmd.run("ruby 3des_rsa.rb #{plaintext}")
when 'd'
puts "Enter the encoded ciphertext: "
ciphertext = gets.chomp
prompt.keypress("Press any key to continue...")
cmd = TTY::Command.new
cmd.run("ruby 3des_rsa.rb #{ciphertext}")
else
puts "The choice was invalid. Enter 'e' or 'd' "
end
when 'ecc_aes'
puts "Enter 'e' for encryption or 'd' for decryption: "
choice = gets.chomp.downcase
case choice
when 'e'
puts "Enter the english plaintext: "
plaintext = gets.chomp
prompt.keypress("Press any key to continue...")
cmd = TTY::Command.new
cmd.run("ruby ecc_aes.rb #{plaintext}")
when 'd'
puts "Enter the encoded ciphertext: "
ciphertext = gets.chomp
prompt.keypress("Press any key to continue...")
cmd = TTY::Command.new
cmd.run("ruby ecc_aes.rb #{ciphertext}")
else
puts "The choice was invalid. Enter 'e' or 'd' "
end
when 'ecc_blowfish'
puts "Enter 'e' for encryption or 'd' for decryption: "
choice = gets.chomp.downcase
case choice
when 'e'
puts "Enter the english plaintext: "
plaintext = gets.chomp
prompt.keypress("Press any key to continue...")
cmd = TTY::Command.new
cmd.run("ruby ecc_blowfish.rb #{plaintext}")
when 'd'
puts "Enter the encoded ciphertext: "
ciphertext = gets.chomp
prompt.keypress("Press any key to continue...")
cmd = TTY::Command.new
cmd.run("ruby ecc_blowfish.rb #{ciphertext}")
else
puts "The choice was invalid. Enter 'e' or 'd' "
end
when 'exit'
exit
end