-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCaesarDecrypt.py
More file actions
33 lines (23 loc) · 832 Bytes
/
CaesarDecrypt.py
File metadata and controls
33 lines (23 loc) · 832 Bytes
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
import pyperclip
message = input("message to encrypt: ")
key = 13
mode = "decrypt"
SYMBOLS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 !?."
translated = ""
for symbol in message:
if symbol in SYMBOLS:
symbolIndex = SYMBOLS.find(symbol)
if mode == "encrypt":
translatedIndex = symbolIndex + key
elif mode == "decrypt":
translatedIndex = symbolIndex - key
if translatedIndex >= len(SYMBOLS):
translatedIndex = translatedIndex - len(SYMBOLS)
elif translatedIndex < 0:
translatedIndex = translatedIndex + len(SYMBOLS)
translated = translated + SYMBOLS[translatedIndex]
else:
translated = translated + symbol
print(translated)
pyperclip.copy(translated)
input()