-
Notifications
You must be signed in to change notification settings - Fork 17
/
lab13.py
66 lines (55 loc) · 2.18 KB
/
lab13.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
########################################################################
# Program:
# Lab 13: Create a cipher
# Author:
# Br. Helfrich, Kyle Mueller
# Summary:
# This program will be able to encrypt and decrypt text using a
# cipher.
########################################################################
import example
import cipher
#############################################################
# GET REPORT
# Generates the report for the selected cipher.
#############################################################
def get_report(cipher):
# get the text
plaintext = input("Please enter the text: ")
if plaintext == "":
plaintext = "I am just \"plain\" text ~ 12345."
# get the password
password = input("Please enter the password: ")
if password == "":
password = "P@55w0rd!"
print(f"Default password: {password}")
encrypted = cipher.encrypt(plaintext, password)
decrypted = cipher.decrypt(encrypted, password)
print("==================================="
"===================================\n"
"Cipher Name: "
f"{cipher.get_cipher_name()}\n" \
"Student Name: "
f"{cipher.get_author()}\n" \
"==================================="
"===================================\n"
"Citation:\n"
f"{cipher.get_cipher_citation()}\n"
"==================================="
"===================================\n"
f"Plain text: {plaintext}\n" \
f"Cipher text: {encrypted}\n" \
f"Decipher text: {decrypted}\n" \
"==================================="
"===================================\n"
"Pseudocode:\n"
f"{cipher.get_pseudocode()}")
#####################################################################
# MAIN
# drives the UI
#####################################################################
def main():
the_cipher = example.Example() # TODO: replace with your cipher class
get_report(the_cipher) # generate the report
if __name__ == "__main__":
main()