Modular Math and the Shift Cipher
The Caesar Cipher is a type of shift cipher. Shift Ciphers work by using the
modulo operator to encrypt and decrypt messages. The Shift Cipher has a key
K,
which is
an integer from 0 to 25. We will only share this key with people
that we want to see our message.
How to Encrypt:
For every letter in the message
M :
-
Convert the letter into the number that matches its order in the alphabet starting from 0, and call this number X.
( A = 0, B = 1, C = 2, ...,Y = 24, Z = 25)
-
Calculate: Y = (X + K) mod 26
-
Convert the number Y into a letter that matches its order in the alphabet starting from 0.
( A = 0, B = 1, C = 2, ...,Y = 24, Z = 25)
For Example:
We agree with our friend to use the Shift Cipher with key
K = 19 for our message. We encrypt the message
caesar, as follows: So, after applying the Shift Cipher with key K = 19 our message
text
caesar gave us cipher text
vtxltk. We give the message
vtxltk to our friend.
How to decrypt:
For every letter in the cipher text
C :
-
Convert the letter into the number that matches its order in the alphabet starting from 0, and call this number Y.
( A = 0, B = 1, C = 2, ...,Y = 24, Z = 25)
-
Calculate: X = (Y - K) mod 26
-
Convert the number X into a letter that matches its order in the alphabet starting from 0.
( A = 0, B = 1, C = 2, ...,Y = 24, Z = 25)
Our friend now decodes the message using our agreed upon key
K = 19. As follows: So, after decrypting the Shift Cipher with key
K = 19 our friend deciphers the cipher text
vtxltk into the message text
caesar.
How to use the Cipher Calculator?
type : Select the encryption method you want
Range : Specify the domain you want to encode, whether uppercase or lowercase letters, or both
Just enjoy. 😄