So I am not use to python and have been given a quick task, a caesar cipher. I wrote that and they want a key word, which is the infromation needed to trasnform the plaintext into encrypted mesage and is also used by the recipient to decrypt the message. But I dont know how to write that in, my code is below and should be indented as it is.
def caesar(plain_text, shift):
cipherText = ''
for ch in plain_text:
stayInAlphabet = ord(ch) + shift
if ch.islower():
if stayInAlphabet > ord('z'):
stayInAlphabet -= 26
elif stayInAlphabet < ord('a'):
stayInAlphabet += 26
elif ch.isupper():
if stayInAlphabet > ord('Z'):
stayInAlphabet -= 26
elif stayInAlphabet < ord('A'):
stayInAlphabet += 26
finalLetter = chr(stayInAlphabet)
cipherText += finalLetter
print(cipherText)
return cipherText
selection = input("Would you like to decrypt or encrypt a message? Please enter 'E' or 'D': ")
if selection == 'encrypt':
Cipher = input("Enter text to Cipher: ")
offset = (int(input("Please enter your offset: "))) % 26
caesar(Cipher, offset)
else:
Cipher = input("What is your Cipher? ")
offset = ((int(input("What is your offset? "))) % 26) * -1
caesar(Cipher, offset)