DIGITAL SOLUTIONS


Caesar Cipher

Background

Its earliest use credited to Julias Caesar, the Caesar chipher is a simple shift cipher, also known as a substitution cipher. This means that the individual letters of the message are rearranged or shifted by some common number. This number is known as the key.

For example, Julias Caesar supposedly always used the number 3 as his encryption key. This would substitute the letter 'D' for an 'A', an 'E' for a 'B' and so on...


Cipher Wheel

A cipher wheel can be a useful tool for quickly working out the character substition with a known shift key.

An online, interactive cipher wheel can be found here: http://inventwithpython.com/cipherwheel/


Try for yourself...





Encrypt Decrypt







Algorithm

    BEGIN
        INPUT plaintext
        UPCASE plaintext
        INPUT key
        INPUT mode

        SET alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
        SET result = ''

        FOR each character in message
            IF character in alphabet THEN
                pos = position of character in alphabet
                IF mode = 'encrypt' THEN
                    result = result + alphabet[(pos + key) mod 26]
                ELSEIF mode = 'decrypt' THEN
                    result = result + alphabet[(pos - key) mod 26]
                ENDIF
            ELSE
                result = result + character
            ENDIF
        ENDFOR

        OUTPUT result
    END