Basic Caesar Cipher. I know its a lot but please do it how it says, I cant understand it.
Program1 Modified Caesar C Basic Caesar Cipher In cryptography, a Caesar Cipher is one of the simplest and most widely known encryption techeiques. It is a type of subatituion cipher in which each letler in the plaintest is replaced by a letter some fixed number of positions down the alphabet. Foe example, with a left shift of 3, D would be replacod by A, E would become B, and so on. The method is named affcr Jliu In a Cacsar Cipher, the encryption is performed against a key string, which is ofien just the 56 letters of the alphabet. An effset value is defined that consists of a positive or negative ineger The plaintest (the nomal text) is encrypted, one letter at a time, by using that offiset value in the followig way: (a) the index poition within the ley shing of e lenet to be encrypled ts determined. (b) the offsct value is appliod to that index in oeder to obtain a new index within the key string(c) the character at the new index is written as the cpher test For a simple example, let's assume the key string consists of the 26 leters of the alphabet plus a pace CS1328-Intredection to Pregramming page: 2 Here we have the 26 letters of the English alphabet plus a space with their index positions listed above. (To simplufy, we'l stick with ll caps oe the moment.) We want to encrypt the phrase I LOVE TO FLY using an offset of +s. We get the following t LOVE TO FLY Cipher tex:NEQT JEYTEKOC Nete that T has an index of 8 wihin the key string. When we add 5 we get an index of 13, which corresponds to the leter N" also within the key string We then write down that leer as thc first character of the encrypted text Smularlythc lenet'Y' has an index of 24 When "K add 5 we pet 29, but since that index doesn't exist within the aray we "urap around" and replace the .Y' with a 'C (Note that the .'Ots not counted. > To decrypt a message, we apply the offsct value in reverse. If the offscts woe added so prodace the cipher test, then they should be subtracted to rcconstitule the plaintest Cipher tex:NEQT JEYTEKOO Plain test Here the plaintest is obtained rom the cipher test by subtracting a constant offsct o S. Nole that with this technique, spaces are treated just like any other character. Note also that we did not aocess the ASCII table in any way. All offisets are callowlated within the key string only Modification of the Caesar Cipher The basic Caesar Cipher has a characteristic that makes it relatively easy to break: every churacter in the plain test is encoded with the same character in the cipher lext. In the above example, every spa is encoded with an 'E. Since the space is the most commonly used churacier, an obscrvan readcr could assume that a space is represented by an E and determing the offset from that A variation on the basie Cacsar Cipher uses a variable offset, one that is different for each churacter encoded. In this algorithm, the fest character of the plain test will be mcoded by some firstomict as above. the nest character is encoded by (interset. 1)the next by(finoset+2), e. As you can see, the offsets grow sequentially from the first character ofthe plain text to the las. T a ensures that instances of a character in e plan lest will be fepresenled by dif|ret characters in the eipher lext Program1 Modified Caesar C Basic Caesar Cipher In cryptography, a Caesar Cipher is one of the simplest and most widely known encryption techeiques. It is a type of subatituion cipher in which each letler in the plaintest is replaced by a letter some fixed number of positions down the alphabet. Foe example, with a left shift of 3, D would be replacod by A, E would become B, and so on. The method is named affcr Jliu In a Cacsar Cipher, the encryption is performed against a key string, which is ofien just the 56 letters of the alphabet. An effset value is defined that consists of a positive or negative ineger The plaintest (the nomal text) is encrypted, one letter at a time, by using that offiset value in the followig way: (a) the index poition within the ley shing of e lenet to be encrypled ts determined. (b) the offsct value is appliod to that index in oeder to obtain a new index within the key string(c) the character at the new index is written as the cpher test For a simple example, let's assume the key string consists of the 26 leters of the alphabet plus a pace CS1328-Intredection to Pregramming page: 2 Here we have the 26 letters of the English alphabet plus a space with their index positions listed above. (To simplufy, we'l stick with ll caps oe the moment.) We want to encrypt the phrase I LOVE TO FLY using an offset of +s. We get the following t LOVE TO FLY Cipher tex:NEQT JEYTEKOC Nete that T has an index of 8 wihin the key string. When we add 5 we get an index of 13, which corresponds to the leter N" also within the key string We then write down that leer as thc first character of the encrypted text Smularlythc lenet'Y' has an index of 24 When "K add 5 we pet 29, but since that index doesn't exist within the aray we "urap around" and replace the .Y' with a 'C (Note that the .'Ots not counted. > To decrypt a message, we apply the offsct value in reverse. If the offscts woe added so prodace the cipher test, then they should be subtracted to rcconstitule the plaintest Cipher tex:NEQT JEYTEKOO Plain test Here the plaintest is obtained rom the cipher test by subtracting a constant offsct o S. Nole that with this technique, spaces are treated just like any other character. Note also that we did not aocess the ASCII table in any way. All offisets are callowlated within the key string only Modification of the Caesar Cipher The basic Caesar Cipher has a characteristic that makes it relatively easy to break: every churacter in the plain test is encoded with the same character in the cipher lext. In the above example, every spa is encoded with an 'E. Since the space is the most commonly used churacier, an obscrvan readcr could assume that a space is represented by an E and determing the offset from that A variation on the basie Cacsar Cipher uses a variable offset, one that is different for each churacter encoded. In this algorithm, the fest character of the plain test will be mcoded by some firstomict as above. the nest character is encoded by (interset. 1)the next by(finoset+2), e. As you can see, the offsets grow sequentially from the first character ofthe plain text to the las. T a ensures that instances of a character in e plan lest will be fepresenled by dif|ret characters in the eipher lext