Untitled
unknown
python
a year ago
573 B
6
Indexable
import random
import string
c = " " + string.punctuation + string.digits + string.ascii_letters
char = list(c)
key = char.copy()
random.shuffle(key)
(f"Chars = {char}")
(f"Key = {key}")
plain = input("enter a message to encrypt")
cipher = ""
for i in plain:
index = char.index(i)
cipher += key[index]
print(f"Original message is {plain}")
print(f"Encrypted is {cipher}")
cipher = input("enter a message to decrypt")
plain = ""
for i in cipher:
index = key.index(i)
plain += char[index]
print(f"Original message is {plain}")Editor is loading...
Leave a Comment