11. Inheritance and Polymorphism

11.5. Special Topic: Historical Cryptography

Cryptography, the study of secret writing, has had a long and interest- ing history. Modern-day cryptographic techniques employ sophisticated mathematics to encrypt and decrypt messages. Today’s most secure encryp- tion schemes are safe from attack by even the most powerful computers. Given our widespread dependence on computers and the Internet, secure encryption has become an important application area within computer science. While the cryptographic techniques used up through World War II are too simple to serve as the basis for modern-day encryption schemes, they can provide an interesting and accessible introduction to this impor- tant area of computer science.

One of the earliest and simplest ciphers is the Caesar cipher, used by Julius Caesar during the Gallic wars. According to this scheme, letters of the alphabet are shifted by three letters, wrapping around at the end of the alphabet:

,,

 

J

When encrypting a message, you take each letter of the message and re- place it with its corresponding letter from the shifted alphabet. To decrypt a secret message, you perform the operation in reverse—that is, you take the letter from the shifted alphabet and replace it with the correspond- ing letter from the plaintext alphabet. Thus, “hello” would be Caesar en- crypted as “khoor.”

The Caesar cipher is a substitution cipher, because each letter in the plaintext message is replaced with a substitute letter from the ciphertext alphabet. A more general form of a substitution cipher uses a keyword to create a ciphertext alphabet:

,,

 

J

In this example, the keyword “xylophone,” (with the second o removed) is used to set up a substitution alphabet. According to this cipher, the word “hello” would be encrypted as “epddi.” Substitution ciphers of this form are found frequently in cryptogram puzzles in the newspapers.

Another type of cipher is known as a transposition cipher. In this type of cipher, the letters in the original message are rearranged in some me- thodical way. A simple example would be if we reversed the letters in each word so that “hello” became “olleh.”