Skip to main content
Logo image

Java, Java, Java: Object-Oriented Problem Solving, 2022E

Section 8.5 Special Topic: Historical Cryptography

Cryptography, the study of secret writing, has had a long and interesting history. Modern-day cryptographic techniques employ sophisticated mathematics to encrypt and decrypt messages. Today’s most secure encryption 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.
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:
PlainText:     abcdefghijklmnopqrstuvwxyz
CaesarShifted: defghijklmnopqrstuvwxyzabc
When encrypting a message, you take each letter of the message and replace 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 corresponding letter from the plaintext alphabet. Thus, “hello” would be Caesar encrypted 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:
PlainText:  abcdefghijklmnopqrstuvwxyz
Ciphertext: xylophneabcdfgijkmqrstuvwz
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 methodical way. A simple example would be if we reversed the letters in each word so that “hello” became “olleh.”
You have attempted of activities on this page.