Digital Technologies Digital Solutions ICT Applied Download Resources Web Applications Games Recycle Bin
print("Caesar Cipher")
plain_text = input("Enter plaintext message to encrypt: ")
cipher_text = []
for character in list(plain_text):
  #normalise characters for shifting by using a base 26 (0-25) ordinal system:
  plain_ordinal = ord(character) - ord("A") if character.isupper() else ord(character) - ord("a")
  #shift +3, and wrap using Modulo operator (%) if over length of alphabet (26):
  cipher_ordinal = (plain_ordinal + 3) % 26
  #return cipher as all uppercase to avoid patterns, as randomness makes for stronger encryption:
  cipher_text.append( chr( cipher_ordinal + ord("A") ) )
print("Encrypted ciphertext:", "".join(cipher_text))