Caesar CipherA simple displacement cipher, apparently used by one of the many Caesars to send secret messages. It relies on a KEY (displacement) and rolling alphabet.
Remember, the original cipher used GREEK letters, apparently Julius always used the KEY of 3, making the subsequent decoding much simpler. It encrypts LETTERS only, spaces and punctuation remain unchanged.
Cipher wheel from https://inventwithpython.com/cipherwheel/
BEGIN
INPUT message
UPCASE message
INPUT key
INPUT conversiontype
INIT alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
INIT result = ''
FOR each character in message
IF character in alphabet THEN
pos = position of character in alphabet
IF conversiontype = 'encrypt' THEN
result = result + alphabet[(pos + key) mod 26]
ELSEIF conversiontype = 'decrypt' THEN
result = result + alphabet[(pos - key) mod 26]
ENDIF
ELSE
result = result + character
ENDIF
ENDFOR
OUTPUT result
END