0% found this document useful (0 votes)
17 views

Cipher

Uploaded by

Ahmad Khan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Cipher

Uploaded by

Ahmad Khan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Certainly!

Here are concise definitions for each of these concepts:

 Shift Cipher
 Definition:
o The Shift Cipher, also known as the Caesar Cipher, is a type of substitution cipher in
which each letter in the plaintext is shifted a certain number of places down or up the
alphabet.

 Affine Cipher
 Definition:
o The Affine Cipher is a type of monoalphabetic substitution cipher where each letter in
an alphabet is mapped to its numeric equivalent, encrypted using a linear
transformation function, and then converted back to a letter.

 Substitution Cipher
 Definition:
o A Substitution Cipher is a method of encryption where each letter in the plaintext is
replaced with another letter according to a fixed system, creating a ciphertext alphabet.

 Frequency Analysis
 Definition:
o Frequency Analysis is a cryptanalytic technique used to break substitution ciphers by
studying the frequency of letters or groups of letters in the ciphertext and comparing
them to the expected frequencies in the language.

These definitions capture the essence of each concept in a straightforward manner.

1. Shift Cipher

Encryption:

 Choose a shift value (key), say k.

 Replace each letter in the plaintext with the letter that is k positions further down the alphabet.

Example:

 Key: k=3k = 3k=3

 Plaintext: HELLO
 Ciphertext:

o H becomes K (H+3)

o E becomes H (E+3)

o L becomes O (L+3)

o L becomes O (L+3)

o O becomes R (O+3)

 Ciphertext: KHOOR

Decryption:

 Use the shift value (key) k.

 Replace each letter in the ciphertext with the letter that is k positions back up the alphabet.

Example:

 Key: k=3k = 3k=3

 Ciphertext: KHOOR

 Plaintext:

o K becomes H (K-3)

o H becomes E (H-3)

o O becomes L (O-3)

o O becomes L (O-3)

o R becomes O (R-3)

 Plaintext: HELLO

2. Affine Cipher

Encryption:

 Choose keys a and b.

 Encrypt each letter xxx in the plaintext using the formula:

E(x) = (ax+b)mod m E(x) = (ax + b) \mod m E(x)=(ax+b) mod m

Where mmm is the size of the alphabet (e.g., 26 for English).

Example:

 Keys: a=5a = 5a=5, b=8b = 8b=8


 Plaintext: HELLO
 Assuming A=0, B=1, ..., Z=25:

o H (7) -> R (5*7 + 8 = 43, 43 % 26 = 17, 17 -> R)

o E (4) -> C (5*4 + 8 = 28, 28 % 26 = 2, 2 -> C)

o L (11) -> D (5*11 + 8 = 63, 63 % 26 = 11, 11 -> L)

o L (11) -> D

o O (14) -> C (5*14 + 8 = 78, 78 % 26 = 0, 0 -> A)

 Ciphertext: RCDDC

Decryption:

 Find the modular inverse of a modulo m denoted as 𝑎 −1 a.a-1 = 1

 Decrypt each letter y in the ciphertext using the formula:

 D(y) = 𝑎 −1 (y-b)

Example:

 Keys: a=5, b=8

 Ciphertext: RCDDC

 Find

 Decrypt each letter:

o R (17) -> H (21*(17 - 8) = 21*9 = 189, 189 % 26 = 7, 7 -> H)

o C (2) -> E (21*(2 - 8) = 21*-6 = -126, -126 % 26 = 4, 4 -> E)

o D (3) -> L (21*(3 - 8) = 21*-5 = -105, -105 % 26 = 11, 11 -> L)

o D (3) -> L

o C (2) -> O (21*(2 - 8) = 21*-6 = -126, -126 % 26 = 14, 14 -> O)

 Plaintext: HELLO

3. Substitution Cipher

Encryption:

 Choose a substitution alphabet.

 Replace each letter in the plaintext with the corresponding letter in the substitution alphabet.

Example:

 Substitution Alphabet: QWERTYUIOPLKJHGFDSAZXCVBNM


 Plaintext: HELLO
 Ciphertext:

o H becomes I

o E becomes T

o L becomes S

o L becomes S

o O becomes G

 Ciphertext: ITSSG

Decryption:

 Use the substitution alphabet in reverse.

 Replace each letter in the ciphertext with the corresponding letter in the original alphabet.

Example:

 Substitution Alphabet: QWERTYUIOPLKJHGFDSAZXCVBNM

 Ciphertext: ITSSG

 Plaintext:

o I becomes H

o T becomes E

o S becomes L

o S becomes L

o G becomes O

 Plaintext: HELLO

4. Frequency Analysis

Frequency Analysis is used to break substitution ciphers, including the Shift Cipher and the Affine Cipher.

Process:

1. Count Frequencies: Count the frequency of each letter in the cipher text.

2. Compare Frequencies: Compare these frequencies to the known letter frequencies in the
language (e.g., in English, E is the most common letter).

3. Make Guesses: Guess the substitutions based on the frequency analysis.

4. Refine Substitutions: Refine the substitutions by looking for common words and patterns in the
language.
Example:

 Ciphertext: ITSSG

 Frequency Analysis reveals S is the most common letter.

 In English, E is the most common letter. Guess S might correspond to E.

 Refine the guess by analyzing the resulting partially decrypted text and looking for common
words.

In practice, frequency analysis requires some trial and error and a good understanding of the language's
letter frequ

You might also like