Skip to content

Cryptography

Cryptography is the art and science of protecting information by transforming it into a secure format. It has been used for thousands of years to keep secrets safe, from ancient military strategies to modern online banking. The goal of cryptography is to make a message unreadable to anyone except the intended recipient.

At the heart of cryptography are ciphers, which are methods or algorithms used to encrypt (hide) and decrypt (reveal) information. A cipher takes a readable message, called plaintext, and transforms it into an unreadable format, called ciphertext. The only way to turn ciphertext back into plaintext is by using a specific key or set of rules.

Over the centuries, people have developed many kinds of ciphers, ranging from simple methods like shifting letters to highly complex mathematical algorithms. Each one reflects the technology and challenges of its time.

Caesar Cipher

The Caesar cipher is a type of substitution cipher named after Julius Caesar, the famous Roman general. He used this method to send secret messages to his troops over 2,000 years ago.

Every letter in a message (called the plaintext) is replaced by another letter. The new letter is determined by shifting it a certain number of places in the alphabet.

Example

Let’s say we want to use a shift of 3. Here’s what happens:

Plain alphabet:    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Cipher alphabet: D E F G H I J K L M N O P Q R S T U V W X Y Z A B C

So, if your plaintext message is: hello, the encrypted message (called the ciphertext) would be: khoor.

To decode the message, you just reverse the process: shift the letters backward by the same amount.

Caesar Cipher

Monoalphabetic Substitution

In a monoalphabetic substitution cipher, each letter in the plaintext is replaced by a different letter from the alphabet. But unlike the Caesar cipher, where the substitution follows a regular pattern (like shifting by 3), in a monoalphabetic cipher, the substitutions can be completely random. This makes it much harder to guess the key.

To decrypt the message, you need to reverse the substitution. For example, if Z → E in your key, then every Z in the ciphertext becomes E in the plaintext.

Example

Let’s use a simple key for demonstration:

Plain alphabet:   A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Cipher alphabet: Q W E R T Y U I O P A S D F G H J K L Z X C V B N M

If your plaintext is: SECRET The ciphertext becomes: LTEKTZ

It’s much harder to crack than a Caesar cipher because there are so many possible substitutions (about 400 septillion combinations).

However, if someone knows your ciphertext, they might use frequency analysis to break it. In English, some letters (like E, T, and A) appear more often than others, so patterns in the ciphertext can give clues.

The key is often generated by writing a keyword, using its unique letters first as the substitution alphabet (e.g., A = first letter, B = second), and then filling in the rest of the alphabet in order with the unused letters.

Key Mono Substitution

Transposition Cipher

A transposition cipher is a method of encryption where the positions of characters in the plaintext are shuffled or rearranged according to a specific system, but the characters themselves are not altered. Unlike substitution ciphers, which replace characters with other characters or symbols, transposition ciphers preserve the original characters but change their order.

One common type of transposition cipher is the columnar transposition cipher.

Example - Columnar Transposition

  • Plaintext: "WE ARE DISCOVERED"
  • Arrange into rows:

\(\begin{bmatrix}W & E & A & R\\E & D & I & S\\C & O & V & E\\R & E & D & X\end{bmatrix}\)

  • Rearrange columns based on a key (e.g., 3 1 4 2):

\(\begin{bmatrix}A & W & R & E\\I & E & S & D\\V & C & E & O\\D & R & X & E\end{bmatrix}\)

  • Ciphertext: "AWRDIESCVEOXED"

Transposition techniques are rarely used on their own in modern cryptography but are foundational in understanding more complex encryption systems. They are sometimes combined with substitution in classical ciphers for stronger encryption.

Porta Cipher

A polyalphabetic substitution cipher is a type of cipher where each letter in the plaintext is substituted by a letter from a set of multiple possible alphabets, rather than just one. This means the same letter in the plaintext can be replaced by different letters in the ciphertext depending on its position in the message or a key.

The Porta Cipher is a polyalphabetic substitution cipher. It was invented by Giovanni Battista della Porta in the 16th century and uses paired letters to encode the plaintext.

Porta Table

Porta used 13 encryption alphabets. In all these alphabets, each letter is replaced by the one that is just above or just below. For example, in the first alphabet, a is replaced by n and vice versa. The letters of the keyword indicate which alphabet to use.

Example

Porta Example

Book cipher

A number cipher using a book as a key, often called a book cipher, is a cryptographic technique where numbers refer to specific positions (e.g., page, line, word, or letter) in a pre-agreed book or text. The book serves as the key to both encode and decode the message.

Vignere cipher

Beautfort cipher