Cryptography – Chapter 2: Simple Cryptosystems (Part 1)

cryptography

Cryptography

What are some classical, simple cryptosystems?

Screen Shot 2016-07-13 at 3.31.10 PM.pngFigure 1. Classical Cryptosystems Classification

As shown in the figure, simple cryptosystems can be divided into two main types: Substitution and Transpositional. In this chapter we will only consider about the Substitution.

We can encrypt a message by substituting each character one by one (Mono Alphabetic) or by substituting a block of characters by a block of character (Poly Alphabetic).

First, let have a closer look on Mono Alphabetic – Shift, Substitution and Affine Cipher.

1. Shift Cipher

The encryption rule is simple. Shift the current letter k positions to get the new letter. This can be written in mathematic form as: x → (x+k) mod 26.
The decryption rule is the inverse of the formula: y → (y-k) mod 26.

For example: Given key k = 3, encrypt the message itishottoday.

  • Convert into integers: itishottoday → 8 19 8 18 7 14 19 19 14 3 0 24
  • Encrypt by adding k then modular 2611 22 11 21 10 17 22 22 17 6 3 1
  • Convert into characters: 11 22 11 21 10 17 22 22 17 6 3 1 → lwlvkrwwgdb

2. Substitution Cipher

Given a table defining which character will be replaced by another one, based on the table, we can encrypt and decrypt the message.

For example: Encrypt the message itishottoday based on the following substitution rule:

 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
 d   k   h   l   a   i   c    e   j   b  f   q   g    s    n  m   o  p   z   y  w   t   v    u   x   r

Result: itishottoday ↔ jyjzenyynldt

3. Affine Cipher

Similarly to Shift Cipher, but instead of using solely addition, Affine Cipher also use multiplication for encryption.
Given a and b, the encryption rule is e(x) = (ax + b) mod 26, where gcd(a,26) = 1; 0 ≤ a, b ≤ 25.
For decryption rule, we need to calculate multiplicative inverse of a modular 26, it satisfies the equation a.a-1 ≡ 1 mod 26. The decryption rule is d(y) = a-1 (y – b) mod 26.

For example:

Encryption: Given key a = 5, b = 8 encrypt the message affinecipher.

  • Check key a, b → satisfied
  • Convert into integers: affinecipher → 0 5 5 8 13 4 2 8 15 7 4 17
  • Encrypt by e(x) = (5x + 8) mod 268 7 7 22 21 2 18 22 5 17 2 15 
  • Convert into characters: 8 7 7 22 21 2 18 22 5 17 2 15 →  ihhwvcswfrcp

Decryption: Given key a = 5, b = 8 decrypt the message ihhwvcswfrcp.

  • Check key a, b → satisfied
  • Calculate a-1: 5-1 = 21, since 5.21 ≡ 1 mod 26
  • Convert into integers: ihhwvcswfrcp → 8 7 7 22 21 2 18 22 5 17 2 15
  • Decrypt by d(y) = 21(y – 8) mod 26 → 0 5 5 8 13 4 2 8 15 7 4 17 
  • Convert into characters: 0 5 5 8 13 4 2 8 15 7 4 17 →  affinecipher


End of Chapter 2 – Part 1.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s