-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconsole.py
More file actions
33 lines (24 loc) · 1.19 KB
/
console.py
File metadata and controls
33 lines (24 loc) · 1.19 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
from encoder import Encoder
from decoder import Decoder
def console_using(messages: dict):
option = 0
encoder = Encoder()
decoder = Decoder()
console_text_options = "Choose the cipher:\n"
console_text_options += "".join(str(index) + ". " + value + "\n"
for index, value in enumerate(encoder.get_encryption_options(), start=1))
console_text_options += str(len(encoder.get_encryption_options()) + 1) + ". Exit console\n"
while option > len(encoder.get_encryption_options()) + 1 or option < 1:
option = int(input(console_text_options))
if option > len(encoder.get_encryption_options()) + 1 or option < 1:
print("Incorrect value")
if option == len(encoder.get_encryption_options()) + 1:
print("End console")
return
message = input("Write the message: ")
key = input("Enter the key: ")
secret_message = encoder.cipher(encoder.get_encryption_options(option-1), message, key)
original_message = decoder.decipher(decoder.get_decryption_options(option-1), secret_message, key)
print(f"{secret_message}")
print(f"{original_message}")
messages[secret_message] = original_message