0% found this document useful (0 votes)
17 views47 pages

ch3 Lect 2 Cryptography

cryptography

Uploaded by

hailemariamhg93
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views47 pages

ch3 Lect 2 Cryptography

cryptography

Uploaded by

hailemariamhg93
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 47

Chapter 3

Classical Encryption Technique


 Classical encryption techniques, also known as historical or traditional encryption techniques, are methods of encrypting

messages that were used before the advent of modern cryptographic algorithms.

 These techniques rely on simple mathematical operations and substitution or transposition of characters within the

message.

 Here are a few examples of classical encryption techniques:

 Caesar Cipher:

 Vigenère Cipher:

 Playfair Cipher:

 Rail Fence Cipher:

 Columnar Transposition:
Cont…
Substitution Technique
 Substitution technique is a method used in encryption and cryptography to replace

one element with another.

 It involves substituting characters, symbols, or elements in a message or plaintext

with different characters or symbols to create ciphertext.

 Substitution technique is encryption technique where the characters present in the

original message are replaced by other characters or numbers or symbols.

This technique is commonly used in classical encryption methods and is still utilized

in modern encryption algorithms.


Cont…
The substitution techniques can be explained as follows:

Caesar Cipher.

Monoalphabetic Cipher.

 Polyalphabetic Cipher.

Playfair Cipher.

One-Time Pad.

Hill Cipher
Caesar Cipher
 The Caesar cipher is a simple substitution cipher that is one of the earliest and most well-known encryption

techniques.

 If the plaintext is viewed as a sequence of bits, then substitution involves replacing plaintext bit patterns with

cipher text bit patterns.

 It involves shifting each letter in the plaintext by a fixed number of positions down or up the alphabet.

 Here's how the Caesar cipher works:

 Choose a shift value: This is the number of positions by which each letter will be shifted.

 For example, a shift value of 3 means it is a key=3 that 'A' will be encrypted as 'D', 'B' as 'E', and so on.
Cont…
Convert the plaintext to ciphertext: Go through each letter in the plaintext and shift it according
to the chosen value.
 For example, if the shift value is 3 and the plaintext is "HELLO," the ciphertext would be
"KHOOR."
Decrypting the ciphertext: To decrypt the ciphertext, simply shift each letter back by the same
amount.
 For example, using a shift value of 3, the ciphertext "KHOOR" would be decrypted as
"HELLO" again.
 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.
Here's how modular arithmetic is used in the Caesar cipher

 Assign numerical values to the letters: Each letter of the alphabet is assigned a numerical value. For example,

'A' may be assigned the value 0, 'B' the value 1, and so on up to 'Z' with the value 25.

 Choose a shift value: This is the number of positions by which each letter will be shifted. For example, a shift

value of 3 means that 'A' will be encrypted as 'D,' 'B' as 'E,' and so on

 Encrypting the plaintext: To encrypt a letter, add the shift value to its numerical value and take the result

modulo 26 (the number of letters in the alphabet).

 Decrypting the ciphertext: To decrypt a letter, subtract the shift value from its numerical value and take the

result modulo 26. This brings the letter back to its original position.

 For example, with a shift value of 3, 'D' (3) decrypts to (3 - 3) mod 26 = 0, which corresponds to 'A' in the

plaintext.
Cont…
.
Monoalphabetic Cipher
A monoalphabetic cipher is a substitution cipher where each letter in the plaintext is replaced

by a fixed corresponding letter in the ciphertext.

 It is a type of simple substitution cipher where the substitution is based on a one-to-one

mapping between the letters of the plaintext and the ciphertext.

It is a substitution cipher, where the cipher alphabet for each plain text alphabet is fixed, for

the entire encryption.

In simple words, if the alphabet ‘p’ in the plain text is replaced by the cipher alphabet ‘d’ then

in the entire plain text wherever alphabet ‘p’ is used, it will be replaced by the alphabet ‘d ’to

form the ciphertext.


Here's how a monoalphabetic cipher works:
 Generate a substitution table: Create a table that maps each letter of the alphabet in the plaintext to

a corresponding letter in the ciphertext.

 Encrypting the plaintext: Go through each letter in the plaintext and replace it with the

corresponding letter from the substitution table.

 For example, if 'A' in the plaintext is mapped to 'D' in the substitution table, then 'A' would be

encrypted as 'D'.

 Decrypting the ciphertext: To decrypt the ciphertext, use the reverse mapping. Replace each letter

in the ciphertext with the corresponding letter from the substitution table in reverse.

 For example, if 'D' in the ciphertext is mapped to 'A' in the substitution table, then 'D' would be

decrypted as 'A'.
Cont…
Polyalphabetic Cipher
 A polyalphabetic cipher is a type of substitution cipher that uses multiple substitution alphabets to encrypt the
plaintext.

 Unlike monoalphabetic ciphers, where each letter is consistently substituted with a single corresponding letter,
polyalphabetic ciphers employ different substitution rules based on the position of the letter within the plaintext.

 A polyalphabetic cipher is a cipher where different substitution alphabets are used for various parts of the plaintext
message.

 In polyalphabetic substitution ciphers, the plaintext letters are ciphered differently based upon their installation in
the text.

 Rather than being a one-to-one correspondence, there is a one-to-many relationship between each letter and its
substitutes.

 The most well-known polyalphabetic cipher is the Vigenère cipher, which operates as follows.
Cont…
Generate a keyword: Choose a keyword that will determine the substitution alphabets. The
keyword should be repeated to match the length of the plaintext.

 For example, if the keyword is "KEY" and the plaintext is "HELLO," the keyword would be
repeated as "KEYKE."

 So, to encrypt the word "HELLO" using the Vigenère cipher, you would need a keyword that
determines the sequence of substitution alphabets.

First, we align the keyword with the plaintext:

 Keyword: K E Y K E

 Plaintext: H E L L O
Cont…
Next, we convert the letters of the keyword and the plaintext into numerical values. A

common convention is to assign 'A' or 'a' as 0, 'B' or 'b' as 1, and so on.

 Following this convention, the numerical values for the keyword and plaintext become:

Keyword: 10 4 24 10 4 24

Plaintext: 7 4 11 11 14

Now, we add the numerical values of the keyword and plaintext, modulo 26, to obtain the

ciphertext values.

 Modulo 26 means that if the sum exceeds 25, we wrap back around to 0.
Cont…
 Ciphertext: (10 + 7) % 26 = 17 (R)

 (4 + 4) % 26 = 8 (I)

 (24 + 11) % 26 = 9 (J)

 (10 + 11) % 26 = 21 (V)

 (4 + 14) % 26 = 18 (S)

 So, the word "HELLO" is encrypted to "RIJVS" using the Vigenère cipher with the keyword

"KEY".

To decrypt the ciphertext back to the original plaintext, you would subtract the numerical values of

the keyword from the corresponding ciphertext values, again using modulo 26 arithmetic.
Playfair Cipher
The Playfair cipher is a manual symmetric encryption technique that uses a 5x5 matrix of

letters to encrypt plaintext.

The technique encrypts pairs of letters instead of single letters as in the simple substitution

cipher and rather more complex Vigenère cipher systems then in use.

 It is thus significantly harder to break since the frequency analysis used for simple

substitution ciphers does not work with it.

The Playfair cipher uses a 5 * 5 table containing a key word or phrase.

 Memorization of the keyword and 4 simple rules was all that was required to create the 5

by 5 table and use the cipher.


Cont…
To generate the key table, first fill in the spaces in the table with the letters of the keyword

(dropping any duplicate letters) and then fill the remaining spaces with the rest of the letters of

the alphabet in order (usually omitting "J" or "Q" to reduce the alphabet to fit; other versions put

both "I" and "J" in the same space).

The key can be written in the top rows of the table, from left to right. The keyword together with

the conventions for filling in the 5 by 5 table constitute the cipher key.

To encrypt a message, one would break the message into digrams (groups of 2 letters).

Since encryption requires pairs of letters, messages with an odd number of characters usually

appe3nd an uncommon letter, such as "X", to complete the final digrams.


Cont…
To perform the substitution, apply the following 4 rules, in order, to each pair of letters in

the plaintext:

1. If both letters are the same (only one letter is left), add an "X" after the first letter.

Encrypt the new pair and continue.

Some variants of Playfair use "Q" instead of "X", but any letter, itself uncommon as a

repeated pair, will do.

2. If the letters appear on the same row of your table, replace them with the letters to their

immediate right respectively (wrapping around to the left side of the row if a letter in

the original pair was on the right side of the row).


Cont…
3. If the letters appear on the same column of your table, replace them with the
letters immediately below respectively (wrapping around to the top side of the
column if a letter in the original pair was on the bottom side of the column).

4. If the letters are not on the same row or column, replace them with the letters
on the same row respectively but at the other pair of corners of the rectangle
defined by the original pair.
The order is important – the first letter of the encrypted pair is the one that lies
on the same row as the first letter of the plaintext pair.
Cont…
To decrypt, use the inverse (opposite) of the two shift rules, selecting the letter

to the left or upwards as appropriate.

 The last rule remains unchanged, as the transformation switches the selected

letters of the rectangle to the opposite diagonal, and a repeat of the


transformation returns the selection to its original state.

 The first rule can only be reversed by dropping any extra instances of the

chosen insert letter — generally "X"s or "Q"s — that do not make sense in the
final message when finished.
Example

Key : MONARCHY

 P= HELLO Then Pair p into two letter together

P=HE LL O (HE LX OX) why?

C=CFSUAV
One-Time Pad

The One-Time Pad (OTP) is a cryptographic technique for secure communication that provides

perfect secrecy when used correctly and also known as the Vernam cipher.

The One-Time Pad involves the use of a random key that is at least as long as the plaintext message.

The key is generated only once and is never reused.

It is one of the Substitution techniques which converts plain text into ciphertext.In this mechanism,

we assign a number to each character of the Plain-Text.

The key is made up of random symbols

Key and plain text calculated as modulo 26.


Example of One-Time Pad
Hill Cipher
 The Hill cipher is a polygraphic substitution cipher that operates on blocks of letters.

 It divides the plaintext into blocks of letters, and each block is treated as a single unit during the encryption and decryption

processes. each block is treated as vector. The key matrix is then multiplied with each vector to obtain the corresponding

ciphertext vector.

 So, to encrypt a message , the plaintext is divided into blocks of letters corresponding to the size of the key matrix. Each

block is then converted into a numerical representation (usually using the letters' positions in the alphabet).

 The size of the blocks corresponds to the dimensions of the key matrix and the size of the key matrix is determined by the

number of letters in the chosen alphabet.

 For example, if the alphabet consists of 26 letters (A to Z), the key matrix would typically be a square matrix with

dimensions 2x2 (for pairs of letters) or 3x3 (for triplets of letters), or any larger square matrix depending on the desired

block size.
Cont…
The dimensions of the key matrix must match the number of letters in each block of plaintext or
ciphertext.

If the block size is 2, a 2x2 key matrix would be used. If the block size is 3, a 3x3 key matrix
would be used, and so on.

The matrix used for encryption is the cipher key, and it should be chosen randomly from the set of
invertible n × n matrices (modulo 26).

The key matrix is multiplied with each block of plaintext to obtain the ciphertext block.

The resulting numerical values are converted back into letters to generate the ciphertext.

Similarly, during decryption, the inverse of the key matrix is multiplied with the ciphertext vector
to recover the plaintext vector.
Cont…
By operating on groups of letters, the Hill cipher increases the complexity of

the encryption process and makes it more resistant to frequency analysis attacks.

It was the first polygraphy cipher in which it was practical to operate on more

than three symbols at once.

The Hill cipher is more secure than simple substitution ciphers because it

operates on multiple letters at a time, making it harder to crack through

frequency analysis.
Cont…
Cont…
Cont…
Cont…
Transposition Cipher
A transposition cipher is a type of encryption scheme that rearranges the

letters or characters of a message without changing the actual letters

themselves.

 Instead of substituting letters as in a substitution cipher, a transposition

cipher performs permutation or reordering operations on the plaintext.

Transposition cipher, simple data encryption scheme in which plaintext

characters are shifted in some regular pattern to form ciphertext.


Cont…
In cryptography, a transposition cipher is a method of encryption by which the

positions held by units of plaintext (which are commonly characters or groups of

characters) are shifted according to a regular system, so that the ciphertext

constitutes a permutation of the plaintext.

 It is an encryption method which is achieved by performing permutation over the

plain text and mapping plain text into cipher text using transposition technique is

called transposition cipher.


Cont…
Here's a general overview of how a transposition cipher works:

Choose a rule or pattern for rearranging the plaintext.

Divide the plaintext into chunks or blocks of a fixed size.

Apply the chosen rule to reorder the blocks or characters of the plaintext.

The resulting arrangement is the ciphertext.


Cont…
There are various types of transposition ciphers, each with its own

specific rules for reordering the plaintext.

 Common Transposition Techniques are:

Rail Fence Transposition

Columnar Transposition
Rail fence
 In the rail fence cipher, the plaintext is written downwards diagonally on successive

"rails" of an imaginary fence, then moving up when the bottom rail is reached, down
again when the top rail is reached, and so on until the whole plaintext is written out.
The ciphertext is then read off in rows.

The Rail Fence Cipher is a type of transposition cipher and a transposition cipher

involves the rearranging of the letters in the plaintext to encrypt the message.

This is in contrast to a substitution cipher, in which the plaintext letters are replaced

by letters from another alphabet (or by different letters from the same alphabet).
Cont…
 The rail fence cipher is the simplest transposition cipher.

The steps to obtain cipher text using this technique are as follow:

1. Step 1: The plain text is written as a sequence of diagonals.

2. Step 2: Then, to obtain the cipher text the text is read as a sequence of rows.

Example, Plain Text: meet me Tomorrow In a depth-two rail fence (two rows)

Now, we will write this plain text sequence wise in a diagonal form as you can
see below:
Cont…
 Once you have written the message as a sequence of diagonals, to obtain
the cipher text then read off as a sequence of rows.
So, reading the first row the first half of cipher text will be:
• memtmro
Reading the second row of the rail fence, we will get the second half of
the cipher text:
eteoorw
 Now, to obtain the complete cipher text combine both the halves of
cipher text and the complete cipher text will be:
 Cipher Text: M E M T M R O E T E O O R W
Cont…
Example 2: using three "rails" and a message of 'WE ARE

DISCOVERED FLEE AT ONCE', the ciphered writes out:

Then reads off: Cipher : WECRLTEERD SOEEF EAOCAIVDEN


Decryption
How to decrypt the rain fence cipher text??

Class Work:

Cipher Text: STOOWEYLVYUEIE

Key(Depth): 3

Then what is the Plaintext????


Columnar Transposition
 Columnar Transposition involves writing the plaintext out in rows, and then reading the ciphertext

off in columns.

In its simplest form, it is the Route Cipher where the route is to read down each column in order.

In a columnar transposition, the message is written out in rows of a fixed length, and then read out

again column by column, and the columns are chosen in some scrambled order.

Both the width of the rows and the permutation of the columns are usually defined by a keyword.

 For example, Keyword ZEBRAS is of length 6 (so the rows are of length 6), and the permutation is

defined by the alphabetical order of the letters in the keyword.

 In this case, the order would be "6 3 2 4 1 5".


Cont…
 For example,

Keyword ZEBRAS is of length 6 (so the rows are of length 6), and

The permutation is defined by the alphabetical order of the letters in the

keyword.

 In this case, the order would be "6 3 2 4 1 5".

Encryption Example Keyword: ZEBRAS

Text: WEARE DISCOVERED FLEE AT ONCE


Cont…
Providing five nulls (QKJEU), these letters can be randomly selected
as they just fill out the incomplete columns and are not part of the
message.
Cont…
Decryption, Keyword: ZEBRAS

 Text: EVLNEACDTK ESEAQ ROFOJ DEECU WIREE= 30 Letter

 30/6= 5 row

THEN read row by row to get the plaintext


Cont…
To decrypt the ciphertext "EVLNACDT ESEAROFO DEEC WIREE",

We start similarly to above, by heading the columns with the keyword ZEBRAS.

This time, to find how many rows we need, we do 25 ÷ 6 = 4.16 We round this up
to the next number, which is 5, so we need 5 rows.

The we multiply 6 x 5 we get 30, and 30 - 25 = 5. Hence we need 5 placeholders


in the last row.

After plugin the ciphertext letters in, in the same way as above, we get the above
table.
Common Symmetric Algorithms
 Some of the most popular crypto algorithms are:

 AES (Advanced Encryption Standard)

 DES (Data Encryption Standard)

 IDEA(International Data Encryption Algorithm)

 Blowfish (Drop-in replacement for DES or IDEA)

 RC4 (Rivest Cipher 4)

 RC5 (Rivest Cipher 5)

 RC6 (Rivest Cipher 6)


End of lecture 2

10Q !

You might also like