While substitution cipher takes the plain text alphabets and replace them by other alphabets to generate the ciphertext. Substitution can occur on each alphabets or on group of alphabets. In contrast to substitution, transposition reorders the alphabets. That is, transposition takes the same alphabets but shuffles it around. We will cover transposition in the next module. Let's look at a simple example of a classical cipher based on substitution. Caesar Cipher is the earliest known substitution cipher. The cipher is named after the ancient Roman general Julius Caesar, due to its use in military affairs and private communications. Caesar Cipher replaces each alphabet with the alphabet that is x alphabets after, where the shift x is the encryption key. In other words, you shift the alphabet in the right direction by x alphabets from plain text alphabet to generate the cipher text alphabet. For decryption you reverse the process and replace the cipher text alphabet with the alphabet that is x alphabets earlier. Or the alphabet after doing a left shift by x alphabets. In Caesar Cipher, the key is x or the amount of shift in alphabets. The shift is a cyclic shift. For example, in English, after the alphabet z will follow the alphabet a. So the alphabet set will wrap around itself when doing the shift. Let's consider an example when the key is 2. That is x is equal to 2. Then the Caesar cipher takes the alphabet A and maps it to the alphabet C. Because the shift of one from the alphabet A results in the alphabet B. And the second shift results in the alphabet C. Similarly, Caesar Cipher maps the alphabet B to the alphabet D, the alphabet C to the alphabet E, D to F, and so on. The decryption operation on the other hand will reverse the encryption operation and conduct a left shift by x, which is 2 in this case. Therefore the cipher text alphabet C will be mapped back to the letter A. D back to B, the letter E back to the letter C and so on. So what if you have a plain text that states, meet me later? The Caesar Cipher using the key x=2 will encrypt the plain text to the ciphertext OGGV OG NCVGT, ignoring the spaces. This is because taking the individual letters one by one, the letter M gets mapped into the letter O, the letter E gets mapped into the letter G, T gets mapped into V, and so on. Caesar Cipher operates on each of the alphabets one by one. That is, it takes the first alphabet, encrypts it, then takes the second alphabet and encrypts it, then the third alphabet and so on. Let's try a Caesar Cipher with another key. Suppose the is now key is now x=4. Then Caesar Cipher maps the alphabet, A to the alphabet E. Similarly it maps the letter B to the letter F, C to G and so on. Therefore the plain text MEET ME LATER, gets mapped into QIIX QI PEXIV, using the key of x = 4. Now let's try the key of x = 26. In this case because x is the cyclic shift amount each of the letter gets mapped into itself. If you count 26 letters after the letter A then you would notice that it reaches the letter Z on its 25th count. The next alphabet would be the letter A, because the shift is cyclic. Because each letters maps to itself, the Caesar Cipher will take the plain text message, MEET ME LATER and yield MEET ME LATER as the ciphertext. This is equivalent to having no shift at all, or using x is equal to 0. Let's go back to the x equals to 4 case. Similarly to how x = 26 was equivalent to x equals to 0 due to the cyclic shift, if you use any x, any x where the remainder is 4 after dividing by 26, then they will result in the same encryption process. In other words, Caesar Cipher using any value of the key, where the key x is 26 * i + 4, for any integer i, is equivalent to using the key of x = 4. And the plain text MEET ME LATER, will get mapped to the ciphertext QIIX QI PEXIV. Because of the cyclic shift in Caesar Cipher, its key size, counting only the keys that generate distinct encryption, is the same as the size of the plain text alphabet. If encrypting English letters, then the possible keys providing distinct encryption, are integers between 0 and 25. This is because for any arbitrary integer, a, using x = a is equivalent to using any other integer values that have a remainder of a after dividing it by 26. For example, that a can be 51 or 77, or x, or -1 which is equivalent to doing a reverse shift or a left shift by 1. And all these values will be equivalent to using the key x = 25.