Cryptography Unit 2
Cryptography Unit 2
From the beginning any era, human being has two natural needs:
To communicate and share information and
To communicate selectively.
These two needs gave rise to the art of coding the messages in such a way that only the
intended people could have access to the information. Unauthorized people could not
extract any information.
The word “cryptography‟ is the combination of two Greek words, “Krypto” meaning
hidden or secret and “graphene” meaning writing.
The two primary types of cryptography are symmetric key cryptography and asymmetric key
cryptography and it plays a dynamic role in ensuring the security and privacy of information
in today’s digital world and enables secure online transactions, protects data stored in
databases, and ensures the confidentiality of communication. As technology continues to
advance, cryptography remains a crucial tool in the ongoing battle to keep our information
safe from hackers.
1. Symmetric-key cryptography: This type of cryptography involves the use of a single key to
encrypt and decrypt data. Both the sender and receiver use the same key, which must be kept
secret to maintain the security of the communication.
3. Hash functions: A hash function is a mathematical algorithm that converts data of any size
into a fixed-size output. Hash functions are often used to verify the integrity of data and
ensure that it has not been tampered with.
Applications of Cryptography:
Cryptography has a wide range of applications in modern-day communication, including:
Digital signatures: Digital signatures are used to verify the authenticity and integrity
of digital documents and ensure that they have not been tampered with.
Strong encryption algorithm - Given the algorithm and one or more ciphertexts
• Input is, Message P and the encryption key K - Algorithm forms the Ciphertext C denoted
as C=E(K,P) .
These replace characters in plaintext with other characters according to a fixed system.
Caesar Cipher: Each letter in the plaintext is shifted by a fixed number of positions
in the alphabet.
Playfair Cipher: Uses a 5x5 grid of letters to encrypt digraphs (pairs of letters)
rather than single characters.
2. Transposition Ciphers
Rail Fence Cipher: The message is written in a zigzag pattern and then read row
by row.
Columnar Transposition Cipher: The plaintext is written in a grid and then read
column-wise according to a key.
Route Cipher: The text is written in a grid and read in a specific order (spiral,
diagonal, etc.).
3. Polyalphabetic Ciphers
These use multiple substitution alphabets to make frequency analysis more difficult.
Autokey Cipher: Similar to the Vigenère cipher, but part of the plaintext is used as
the key.
4. Hill Cipher
5. Enigma Machine
6. Vernam Cipher
Secure only if the key is truly random and used only once.
These classical ciphers were effective in their time but are now largely obsolete due to
advances in computational power and cryptanalysis techniques. Modern cryptography
relies on more complex algorithms such as AES, RSA, and ECC, which provide much
stronger security.
Definition
The Caesar Cipher is a basic monoalphabetic substitution cipher where each letter in the
plaintext is shifted by a fixed number of positions in the alphabet.
Encryption Process
2. Replace each letter in the plaintext with a letter shifted forward by k positions.
3. Wrap around the alphabet if needed (e.g., shifting ‘Z’ by 1 gives ‘A’).
Encryption Formula
Where:
C = Ciphertext letter
k = Shift value
Decryption Formula
Where:
C = Ciphertext letter
Example (Shift = 3)
Encryption
Plaintext: HELLO
H→K
E→H
L→O
L→O
O→R
✅ Ciphertext: KHOOR
K→H
H→E
O→L
O→L
R→O
Example:
For the ciphertext "KHOOR", trying all 25 shifts would eventually reveal "HELLO" when
the correct shift (3) is used.
2. Frequency Analysis
🔹 Most effective against all monoalphabetic ciphers.
🔹 In any language, some letters appear more frequently than others.
🔹 For example, in English, the most common letters (by frequency) are:
E, T, A, O, I, N, S, H, R, D, L, U
Example:
Ciphertext: "ZOLSS"
If "S" is the most frequent letter, it might correspond to "E" (most common English
letter).
Example:
If we suspect a military message starts with "ATTACK," we can match it with the
ciphertext and uncover the letter mappings.
Example:
Ciphertext: "XYY XZ YYX"
🔹 The message is written in a zigzag (rail fence) pattern and then read row by row.
mathematica
CopyEdit
H L O O L
EL WRD
L O
Read row-wise:
Ciphertext: HLOOL ELWRD LO
🔹 The message is written in a grid (row-wise), then read column-wise based on a key.
mathematica
CopyEdit
Z E B R A (Key)
-----------
HELLO
WORLD
mathematica
CopyEdit
A B E R Z
O L L L H
D R O W W
3. Route Cipher
🔹 The message is written in a grid, then read in a specific order (spiral, diagonal, etc.).
css
CopyEdit
ATTAC
KATDA
WNXXX
1. Stream Ciphers
Definition
A stream cipher encrypts data one bit or byte at a time, typically using a keystream
generator that produces a pseudo-random sequence of bits. The plaintext is combined
with this keystream using bitwise XOR.
Decryption: P=C⊕KP = C \oplus KP=C⊕K (Reapplying XOR with the same key
restores plaintext)
Generates a keystream from a seed key using KSA (Key Scheduling Algorithm)
and
A block cipher encrypts data in fixed-size blocks (e.g., 64-bit or 128-bit blocks). It applies
a series of mathematical transformations based on a secret key.
Since block ciphers work on fixed-size blocks, they require modes of operation to handle
variable-length messages.
CBC (Cipher Block XORs each block with the previous Prevents pattern
Chaining) ciphertext block before encryption repetition
CFB (Cipher Converts block cipher into a self- Used for streaming
Feedback Mode) synchronizing stream cipher applications
Example
RC4, Salsa20 AES, DES, 3DES
Ciphers