Welcome to
PES University
Ring Road Campus, Bengaluru
30 Aug 2021 1
Applied Cryptography
Lecture 5
30 Aug 2021 2
Classical Cryptography - Decryption
Most of them not in use nowadays
30 Aug 2021 3
Caesar Shift cipher
• C = E (p,k) mod 26 = (p+k) mod 26
• p = D (C,k) mod 26 = (C-k) mod 26
• Key: shift index by 3
• Decrypt GFRGHA with a shift of 3.
1) To decrypt G, take the alphabet and look 3 letters before: D.
2) Mathematically, subtracts a constant (the shift), then the
result modulo 26 (alphabet length) is the plain text.
30 Aug 2021 4
Caesar Shift cipher
• Decrypt GFRGHA with a shift of 3.
• Take G=6, subtract the shift 6-3=3 and 3=D, so G is decrypted
with D.
• Take A=0, 0-3=-3 and -3 mod 26 = 23, 23=X, so A is decrypted
with X, etc.
• GFRGHA is decrypted DCODEX.
30 Aug 2021 5
Playfair Cipher
• A 5x5 matrix is drawn, and letters are filled in each cell, starting
with the keyword, followed by the letters in the alphabet.
• I/J are filled in the same cell.
• All repeating letters are removed.
• Keyword: ‘Charles’
• Ciphertext: gddogdrqprsdhmembv
• gd do gd rq pr sd hm em bv
30 Aug 2021 6
Playfair Cipher
• Two ciphertext letters in the same row are replaced by the
letter to the left, with the last element of the row circularly
following the first. (Eg: sd by eb)
• Two ciphertext letters that fall in the same column are replaced
by the letters above, with the bottom element of the column
circularly following the top. (Eg: my by dt)
• Otherwise, each ciphertext letter in a pair is replaced by the
letter that lies in its own row and the column occupied by the
other ciphertext letter. (Eg: gd by me)
• ‘Meet me at the bridge’ (x is neglected at the end since its a
filler letter)
30 Aug 2021 7
Vigenere cipher
• Tabula Recta
• The keystream “b” means we
choose the column with B at the
top.
• The plaintext “a” means we
choose the row with A at the left.
We get the ciphertext "B".
30 Aug 2021 8
Vigenere cipher
• To decrypt:
• Repeat the keyword and generate the keystream, the same
length as the ciphertext.
• Find the column with the letter of the keystream at the top.
Go down this column until you find the ciphertext letter.
Now read across to the far left of the table to reveal the
plaintext letter.
30 Aug 2021 9
Vigenere cipher
30 Aug 2021 10
Hill cipher
• Plaintext: SHORTER EXAMPLE
• Key: HILL
• Encryption:
• Problem 2: Plaintext = “ATTACK IS TONIGHT”,
• Ciphertext = ATT is FNW
30 Aug 2021 11
Hill cipher - Decrypt
• Ciphertext = APADJ TFTWLFJ, Key = HILL
=
• Find the inverse key matrix
1) Calculate the multiplicative inverse for the
determinant.
2) Value for adjugate matrix (Transpose)
3) Calculate from values received in above
step 1 & step 2
• Use the first two letters from the
ciphertext as ‘AP’ and then multiply with
the inverse matrix for modulo 26.
30 Aug 2021 12
30 Aug 2021 13
Hill cipher (3*3) - Decrypt
• Ciphertext: SYICHOLER
• Key: ALPHABET
• Calculating the multiplicative inverse
for the Determinant.
• Find a number between 1 & 25 that
gives the value of 1 on
multiplication with the determinant
value.
30 Aug 2021 14
Hill cipher (3*3) - Decrypt
• Calculate the Adjugate Matrix.
• Finalising the inverse matrix value.
30 Aug 2021 15
Hill cipher
• Plaintext: RETREAT NOW
• Key: BACK UP
30 Aug 2021 16
Rail fence cipher
• Plaintext - "defend the east wall“
• Key – 2
• Key – 3
"DFNTEATALEEDHESWL"
"DNETLEEDHESWLXFTAAX"
• Decryption: "TEKOOHRACIRMNREATANFTETYTGHH“
• Key - 4
30 Aug 2021 17
Rail fence cipher
We have a table with 4 rows because
the key is 4, and 28 columns as the
ciphertext has length 28.
The second stage in the
decryption process.
The third stage in the
decryption process.
The fourth and final stage
in the decryption
process.
30 Aug 2021 18
Next Class
☞Mandatory reading for the next class
☞ https://users.encs.concordia.ca/~youssef/Publications/Papers/C
ryptanalysis%20of%20Simple%20Substitution%20Ciphers%20Usi
ng%20Particle%20Swarm.pdf
30 Aug 2021 19
Dr. Sivaraman E
Computer Science and Engineering
PES University, Bengaluru
10 June 2020
30 Aug 2021 20