-
Notifications
You must be signed in to change notification settings - Fork 0
/
cryptmsg.py
34 lines (32 loc) · 1023 Bytes
/
cryptmsg.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
#!/usr/bin/env python3
import time
import sys
def caesar_cipher_decrypt(text, shift):
result = ""
for i in range(len(text)):
char = text[i]
if char.isupper():
result += chr((ord(char) - shift - 65) % 26 + 65)
elif char.islower():
result += chr((ord(char) - shift - 97) % 26 + 97)
else:
result += char
return result
def type_with_sound(message, delay=0.1):
for char in message:
sys.stdout.write(char)
sys.stdout.flush()
print('\a', end='', flush=True)
time.sleep(delay)
if __name__ == "__main__":
encrypted_message = (
"Xlmw mw e wigvix qiwweki."
"Srpc xli asvxlc ger higmtliv mx."
"Aipgsqi xs xli qcwxivmsyw asvph sj Tcxlsr!"
"Oiit xlmw gshi weji erh wigyvi."
"Xli xvyxl mw syx xlivi."
)
shift = 4
decrypted_message = caesar_cipher_decrypt(encrypted_message, shift)
type_with_sound(decrypted_message)
#This is Not a Drill. Check out the message