-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCaserCipher.py
More file actions
27 lines (20 loc) · 903 Bytes
/
CaserCipher.py
File metadata and controls
27 lines (20 loc) · 903 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
import pyperclip
message = input("Put your message: ")
key = int(input("Put the key: "))
mode = int(input("Choose the mode:\nEncrypt == 1 || Decrypt == 2 :\t"))
Symbols = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*()_-+=[]{}|\\;:\'",.<>?/`~ '
TranslatedMessage = ''
for symbol in message:
if symbol in Symbols:
SymbolIndex = Symbols.find(symbol)
# Determine the new index based on the mode
if mode == 1: # Encryption
EncryptIndex = (SymbolIndex + key) % len(Symbols)
elif mode == 2: # Decryption
EncryptIndex = (SymbolIndex - key) % len(Symbols)
TranslatedMessage += Symbols[EncryptIndex]
else:
# If the symbol isn't in the Symbols list, keep it as is
TranslatedMessage += symbol
print("Translated Message:", TranslatedMessage)
pyperclip.copy(TranslatedMessage)