Lec Cryptography
Lec Cryptography
Alice Bob
Insecure Channel
Key A Key B
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
En (x) = (x + n) mod 26 k=2
J 9 + 2 mod 26 11 L B 1 + 2 mod 26 3 D
O 14+2 mod 26 16 Q Y 24 + 2 mod 26 0 A
I 8 +2 mod 26 10 K
N 13+2 mod 26 15 P T 19 +2 mod 26 21 V
H 7+2 mod 26 9 J
M 12+2 mod 26 14 O E 4+2 mod 26 6 G
E 4+2 mod 26 6 G
Z 25 + 2 mod 26 1 B
A 0+2 mod 26 2 C O 14+2 mod 26 16 Q
T 19 +2 mod 26 21 V O 14+2 mod 26 16 Q
E 4+2 mod 26 6 G
I 8+2 mod 26 10 K
G 6 +2 mod 26 8 I
H 7+2 mod 26 9 J
T 19+2 mod 26 21 V
Suppose we want to encode the secret
message/plaintext: Spy Coder
• shift value/key value S=5
• Spy Coder
Plaintext: S P Y C O D E R
Cipher text:
• shift value S=2
• JOIN ME AT EIGHT BY THE ZOO
J O I N M E A T E I G H T B Y T H E Z O O
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
J O I N M E A T E I G H T B Y T H E Z O O
Plaintext:
Cipher text: L Q K P O G C V G K I J V D A V J G B Q Q
En (x) = (x + n) mod 26 k=5
S 18 + 5 mod 26 23 X
P 15 + 5mod 26 20 U
Y 24 +5 mod 26 3 D
C 2 + 5 mod 26 7 H
O 14 + 5 mod 26 19 T
D 3+ 5 mod 26 8 I
E 4 + 5 mod 26 9 J
R 17 + 5 mod 26 22 W
Suppose we want to encode the secret
message: Spy Coder E (x) = (x + n) mod 26 k = 5
n
S 18 + 5 mod 26 23 X
• shift value S=5 P 15 + 5mod 26 20 U
Plaintext: S P Y C O D E R C 2 + 5 mod 26 7 H
Cipher text: X U D H T I J W O 14 + 5 mod 26 19 T
D 3+ 5 mod 26 8 I
E 4 + 5 mod 26 9 J
R 17 + 5 mod 26 22 W
Decryption
• Deciphering is done in reverse
• The formula of decryption is:
Dn (x) = (xi - n) mod 26
Decrypt: XUD HTIJW; shift value S=5
X 23 - 5 mod 26 18 S
U 20 - 5mod 26 15 P
D 3 - 5 mod 26 24 Y
H 7 - 5 mod 26 2 C
T 19 - 5 mod 26 14 O
I 8 - 5 mod 26 3 D
J 9 - 5 mod 26 4 E
W 22 - 5 mod 26 17 R
Use the Caesar cipher to encrypt and decrypt the message
"HELLO," and the key (shift) value of this message is 15.
H 7 + 15 mod 26 22 W W 22 - 15 mod 26 7 H
E 4 + 15 mod 26 19 T T 19 -15 mod 26 4 E
L 11 + 15 mod 26 0 A A 0 - 15 mod 26 11 L
L 11 + 15 mod 26 0 A A 0 - 15 mod 26 11 L
O 14 + 15 mod 26 3 D D 3 - 15 mod 26 14 O
Cryptanalysis of Caesar Cipher
• only have 26 possible ciphers
• A maps to A,B,..Z
• could simply try each in turn
• a brute force search
• given ciphertext, just try all shifts of letters
• do need to recognize when have plaintext
• eg. break ciphertext "GCUA VQ DTGCM"
GCUA VQ DTGCM – decipher via brute force
1 FBTZ UP CSFBL 9 17 25
2 EASY TO BREAK 10 18 26
3 DZRX SN AQDZJ 11 19
4 CYQW RM ZPCYI 12 20
5 13 21
6 14 22
7 15 23
8 16 24
Vigenère Cipher
POLYALPHABETIC CIPHER
Polyalphabetic Ciphers
• It uses a simple form of polyalphabetic substitution.
• A polyalphabetic cipher is any cipher based on substitution, using
multiple substitution alphabets.
• The Vigenere key stream dose not depend on the plaintext characters.
It depends only on the position of the character in the plain text.
• Encryption
The plaintext(P) and key(K)
Ei = (Pi + Ki) mod 26
• Decryption
Di = (Ei - Ki) mod 26
Vigenère square or Vigenère table
Key: AYUSH
Plaintext: GEEKFORGEEKS
KEY A Y U S H A Y U S H A Y U
PLAINTEXT G E E K S F O R G E E K S
GCYCZFMLYLEIM G C Y C Z F M L Y L E I M