Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
6 views

Lecture 3

Uploaded by

nadosh.alya
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Lecture 3

Uploaded by

nadosh.alya
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Data Security

LECTURE 3
Elementary / Traditional
Cryptography
• Substitution Ciphers, and
• Transposition Ciphers
Substitution Ciphers & Transposition Ciphers

Substitution Ciphers:
• Each letter or group of letters is replaced by another letter or group of letters
• The plain alphabet rotated left or right by some number of positions.
• Every occurrence of one character will be substituted with the same replacement
character, while its position remains unchanged.
Transposition Cipher Technique:
• Rearranges the position of the plain text’s characters. The position of the character
is changed but character’s identity is not changed.
• Transposition cipher is a type of encryption technique where the positions of the
letters in the plaintext message are rearranged to form a ciphertext message. This
technique does not alter the letters themselves but rather the order in which they
appear.
Substitution Cipher

Monoalphabetic Polyalphabetic

Monoalphabetic cipher is Polyalphabetic cipher is


one where each symbol in any cipher based on
plain text is mapped to a substitution, using multiple
fixed symbol in cipher text. substitution alphabets.

one-to-one One to many


Substitution Ciphers --Monoalphabetic

1- Caesar Cipher:
• Also known as, Caesar's code or Caesar shift:
• Is one of the simplest and most widely known
Encryption techniques.

• Each letter in the Plaintext is replaced by a another


letter with fixed number of positions down
the Alphabet.
Substitution Ciphers
Mathematical representation
The encryption can be represented using modular arithmetic by first transforming
the letters into numbers, according to the scheme, A = 0, B = 1,…, Z = 25.

Encryption of a letter by a shift n can be described mathematically


as:

Decryption of a letter by a shift n can be described mathematically


as.
Substitution Ciphers

Example 1: with a Left Shift of 3,


D would be replaced by A,
E would become B,
and so on.

Example2: with a Right Shift of 23,


A would be replaced by X,
B would become Y,
and so on.
plain 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 X Y Z A B C D E F G H I J K L M N O P Q R S T U V W
Substitution Ciphers
Exercise: use Caesar Cipher method to encrypt
“ computer science”, with key = left shift by 8
characters

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
the order 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

answer: ???
plaintext c o m p u t e r s c i e n c e
ciphertext
Substitution Ciphers & Transposition Ciphers
2- Mono Alphabetic Substitution Cipher
• Relationship between ciphertext symbol and
plaintext symbol is 1:1
• Key value is added to plain text and numeric value
of key ranges from 0 – 25
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
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

Encryption algorithm: Decryption algorithm:


P+k=C C-k=P

Where: P=Plaintext
C=Ciphertext k=key
2- Mono Alphabetic Substitution Cipher

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
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

Example 1: use Mono alphabetic cipher to encrypt “hello”,


key=5
Encryption: Decryption
P+K=C C-K=P
H + 5 = 7 + 5 = 12 = M M - 5 = 12 - 5 = 7 = H
E+5=4+5 =9=J J-5=9-5 =4=E
L + 5 = 11 + 5 = 16 = Q Q - 5 = 16 - 5 = 11 = L
L + 5 = 11 + 5 = 16 = Q Q - 5 = 16 - 5 = 11 = L
O + 5 = 14 + 5 = 19 = T T - 5 = 19 - 5 = 14 = O

C= MJQQT P= HELLO
Implementation of Mono Alphabetic Substitution Cipher
3-Polyalphabetic substitution cipher
“Vigener cipher”

• In polyalphabetic cipher each occurrence of a character may have different


substitution.
• The relationship between characters in plaintext and ciphertext is 1 to many.
3-Polyalphabetic substitution cipher “Vigener cipher”

Example: The plaintext is "JAVATPOINT", and the key is "BEST".


Encryption: Ei = (Pi + Ki) mod 26

Plaintext J A V A T P O I N T

Plaintext
09 00 21 00 19 15 14 08 13 19
value (P)
Key B E S T B E S T B E
Key value
01 04 18 19 01 04 18 19 01 04
(K)

Ciphertext
10 04 13 19 20 19 06 01 14 23
value (E)

Ciphertext K E N T U T G B O X
3-Polyalphabetic substitution cipher “Vigener cipher”

Decryption: Di = (Ei - Ki) mod 26


If any case (Di) value becomes negative (-ve), in this case, we will add 26 in
the negative value. Like, the third letter of the ciphertext;

Ciphertext K E N T U T G B O X

Ciphertext
10 04 13 19 20 19 06 01 14 23
value (E)
Key B E S T B E S T B E
Key value
01 04 18 19 01 04 18 19 01 04
(K)
Plaintext
09 00 21 00 19 15 14 08 13 19
value (P)

Plaintext J A V A T P O I N T
Vigenere Table

MEXI COTE CHNO LOGI CALU NIVE RSITY


HIGH HIGH HIGH HIGH HIGH HIGH HIGH
4-Playfair Cipher

• In playfair cipher, initially a key table is created.


• The key table is a 5×5 grid of alphabets.
• Usually (J) is omitted from the Key table.
• If the plaintext contains J, then it is replaced by I.
• The sender and the receiver deicide on a particular key, say
‘tutorials’.
• In a key table, the first characters (going left to right) in the
table, excluding the duplicate letters.
• The rest of the table will be filled with the remaining letters of
the alphabet, in natural order
4-Playfair Cipher

Example: Use playfair Cipher to encrypt the message “hide


money” , key = ‘tutorials’
Process of Playfair Cipher
• First, a plaintext message is split into pairs of two letters
(digraphs).
• If there is an odd number of letters, a Z is added to the last
letter.
Plaintext: HI DE MO NE YZ
4-Playfair Cipher

The Rules of Encryption are:


1- If both the letters are in the same column, take the letter below
each one.
Plaintext: HI DE MO NE YZ

T U O R I

A L S B C

D E F G H ‘H’ and ‘I’ are in same column,


HI → QC
K M N P Q

V W X Y Z
4-Playfair Cipher

The Rules of Encryption are:


2- If both letters are in the same row, take the letter to the right of
each one (going back to the left if at the farthest right)

Plaintext: HI DE MO NE YZ

T U O R I
A L S B C
‘D’ and ‘E’ are in same row
D E F G H
DE → EF
K M N P Q
V W X Y Z
4-Playfair Cipher

The Rules of Encryption are:


3- If neither of the preceding two rules are true, form a
rectangle with the two letters and take the letters on the
horizontal opposite corner of the rectangle
Plaintext: HI DE MO NE YZ
T U O R I
A L S B C ‘M’ and ‘O’ nor on same column or same
row, then replace letter by picking up
D E F G H
opposite corner letter on the same row
K M N P Q MO >>NU
V W X Y Z
4-Playfair Cipher

Using these rules, the result of the encryption of “hide money” with
the key of ‘tutorials’ would be:
QC EF NU MF ZV

Decrypting:
• The Playfair cipher is as simple as doing the same
process in reverse.
• Receiver has the same key and can create the same
key table, and then decrypt any messages made using
that key.
Cipher Text: "gatlmzclrqtx"
Decrypted Text: instrumentsz Decryption Process
Key text: Monarchy

You might also like