import random
import string
chars = list(" " + string.punctuation + string.ascii_letters + string.digits)
key = chars.copy()
random.shuffle(key)
userInput = list(input("Input the text you'd like encrypted: "))
for i, character in enumerate(userInput):
currentCharacterInChars = chars.index(character)
userInput[i] = key[currentCharacterInChars]
userInput = "".join(userInput)
print(userInput)
#A simple encryption program
6 messages · Page 1 of 1 (latest)
Great. So how will you decrypt it?
uhh just the ol switcharoo
for i, encryptedCharacter in enumerate(userInput):
currentCharacterInKey = key.index(encryptedCharacter)
userInput[i] = chars[currentCharacterInKey]
But if your key is in effect randomly generated, then you could not decrypt something that was encrypted in a different Python session.
uh i dunno then