-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcc_decrypt.py
32 lines (24 loc) · 918 Bytes
/
cc_decrypt.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
import string
from time import sleep
alphabet = string.ascii_lowercase # "abcdefghijklmnopqrstuvwxyz"
def decrypt():
print("Welcome to Caesar Cipher Decryption.\n")
encrypted_message = input("Enter the message you would like to decrypt: ").strip()
print()
key = int(input("Enter key to decrypt: "))
decrypted_message = ""
for c in encrypted_message:
if c in alphabet:
position = alphabet.find(c)
new_position = (position - key) % 26
new_character = alphabet[new_position]
decrypted_message += new_character
else:
decrypted_message += c
print("\nDecrypting your message...\n")
sleep(2) # give an appearance of doing something complicated
print("Stand by, almost finished...\n")
sleep(2) # more of the same
print("Your decrypted message is:\n")
print(decrypted_message)
decrypt()