SlideShare a Scribd company logo
3
Most read
4
Most read
5
Most read
Unit 3: Classical and Modern Encryption Techniques
Prepared By : Dr C D Bawankar
Unit 3: Classical and Modern Encryption Techniques
2. Modern Encryption Techniques
o RC4 Stream Cipher, Symmetric Encryption (AES), Asymmetric Encryption (RSA)
Symmetric and Asymmetric Encryption: AES & RSA
Encryption is the process of converting plaintext into ciphertext to secure data from unauthorized
access. There are two main types of encryption:
1. Symmetric Encryption (Same key for encryption & decryption)
2. Asymmetric Encryption (Different keys for encryption & decryption)
1. Symmetric Encryption - AES (Advanced Encryption Standard)
Overview
• AES is a block cipher that encrypts data in fixed-size blocks (128-bit).
• Uses the same key for encryption and decryption.
• Developed by Vincent Rijmen and Joan Daemen and adopted as a standard by NIST in
2001.
• AES supports key sizes of 128-bit, 192-bit, and 256-bit.
• Faster than asymmetric encryption.
• Used in SSL/TLS, Wi-Fi Security (WPA2), and VPNs.
AES Algorithm Steps
AES operates in multiple rounds (10 for 128-bit key, 12 for 192-bit, 14 for 256-bit):
1. Key Expansion: Generates multiple round keys from the initial key.
2. Initial Round:
o AddRoundKey (XOR plaintext with the key)
3. Main Rounds (Repeated):
o SubBytes (Byte substitution using an S-box)
o ShiftRows (Row-wise shifting of bytes)
o MixColumns (Matrix multiplication to mix data)
o AddRoundKey
4. Final Round (No MixColumns)
o SubBytes
o ShiftRows
o AddRoundKey
Numerical Example of AES (Simplified)
Given Data:
• Plaintext (16 bytes): "HELLO_WORLD_AES!" (ASCII representation)
• Key (16 bytes, 128-bit): "THIS_IS_MY_KEY!!"
Convert plaintext & key to binary:
H = 01001000 E = 01000101 L = 01001100 L = 01001100
O = 01001111 _ = 01011111 W = 01010111 O = 01001111
Unit 3: Classical and Modern Encryption Techniques
Prepared By : Dr C D Bawankar
R = 01010010 L = 01001100 D = 01000100 _ = 01011111
A = 01000001 E = 01000101 S = 01010011 ! = 00100001
1.
2. AddRoundKey (Initial XOR with key).
3. SubBytes (Byte substitution using S-box).
4. ShiftRows (Rearrange rows).
5. MixColumns (Mathematical transformation).
6. Repeat for 10 rounds (for 128-bit key).
7. Ciphertext Output: Binary converted back to text.
Python Program for AES Encryption
Using pycryptodome library:
from Crypto.Cipher import AES
import base64
# Function to pad plaintext to be multiple of 16 bytes
def pad(text):
return text + (16 - len(text) % 16) * chr(16 - len(text) % 16)
# Function to encrypt using AES
def aes_encrypt(plain_text, key):
cipher = AES.new(key.encode('utf-8'), AES.MODE_ECB) # ECB mode
return base64.b64encode(cipher.encrypt(pad(plain_text).encode('utf-8'))).decode('utf-8')
# Function to decrypt using AES
def aes_decrypt(cipher_text, key):
cipher = AES.new(key.encode('utf-8'), AES.MODE_ECB)
decrypted = cipher.decrypt(base64.b64decode(cipher_text)).decode('utf-8')
return decrypted.rstrip(decrypted[-1]) # Remove padding
# Example usage
key = "THIS_IS_MY_KEY!!" # 16-byte key
plaintext = "HELLO_WORLD_AES!"
encrypted = aes_encrypt(plaintext, key)
print("Encrypted Text:", encrypted)
decrypted = aes_decrypt(encrypted, key)
print("Decrypted Text:", decrypted)
Unit 3: Classical and Modern Encryption Techniques
Prepared By : Dr C D Bawankar
2. Asymmetric Encryption - RSA (Rivest-Shamir-Adleman)
Overview
• RSA is an asymmetric encryption algorithm that uses two keys:
o Public Key (for encryption)
o Private Key (for decryption)
• Developed by Ron Rivest, Adi Shamir, and Leonard Adleman in 1977.
• Used in SSL/TLS, Digital Signatures, and Secure Communications.
• Slower than AES but provides stronger security.
RSA Algorithm Steps
1. Key Generation:
o Choose two large prime numbers p and q.
o Compute n = p × q (modulus).
o Compute ϕ(n) = (p - 1) × (q - 1) (Euler's totient function).
o Choose an encryption exponent e such that 1 < e < ϕ(n) and gcd(e, ϕ(n)) = 1.
o Compute decryption exponent d such that (e × d) mod ϕ(n) = 1.
o Public Key: (n, e), Private Key: (n, d).
2. Encryption:
C=(Pe)mod nC = (P^e) mod nC=(Pe)modn
where P is plaintext, C is ciphertext.
3. Decryption:
P=(Cd)mod nP = (C^d) mod nP=(Cd)modn
using private key (n, d).
Numerical Example of RSA
Given:
• Choose p = 3, q = 11
• Compute n = 3 × 11 = 33
• Compute ϕ(n) = (3 - 1) × (11 - 1) = 2 × 10 = 20
• Choose e = 7 (since gcd(7, 20) = 1)
• Compute d such that (7 × d) mod 20 = 1, so d = 3
• Public Key: (n = 33, e = 7), Private Key: (n = 33, d = 3)
Encryption:
Unit 3: Classical and Modern Encryption Techniques
Prepared By : Dr C D Bawankar
• Plaintext (P) = 5
• Ciphertext C = (5^7) mod 33 = 78125 mod 33 = 14
Decryption:
• P = (C^d) mod n = (14^3) mod 33 = 2744 mod 33 = 5
Decrypted message matches the original plaintext!
•
Unit 3: Classical and Modern Encryption Techniques
Prepared By : Dr C D Bawankar
•
Unit 3: Classical and Modern Encryption Techniques
Prepared By : Dr C D Bawankar
Python Program for RSA
Using cryptography library:
from Crypto.PublicKey import RSA
from Crypto.Cipher import PKCS1_OAEP
import base64
# Generate RSA key pair
key = RSA.generate(1024)
public_key = key.publickey().export_key()
Unit 3: Classical and Modern Encryption Techniques
Prepared By : Dr C D Bawankar
private_key = key.export_key()
# Encrypt function
def rsa_encrypt(plaintext, public_key):
recipient_key = RSA.import_key(public_key)
cipher_rsa = PKCS1_OAEP.new(recipient_key)
encrypted_text = cipher_rsa.encrypt(plaintext.encode())
return base64.b64encode(encrypted_text).decode()
# Decrypt function
def rsa_decrypt(ciphertext, private_key):
private_key = RSA.import_key(private_key)
cipher_rsa = PKCS1_OAEP.new(private_key)
decrypted_text = cipher_rsa.decrypt(base64.b64decode(ciphertext))
return decrypted_text.decode()
# Example usage
plaintext = "Hello RSA!"
encrypted = rsa_encrypt(plaintext, public_key)
print("Encrypted Text:", encrypted)
decrypted = rsa_decrypt(encrypted, private_key)
print("Decrypted Text:", decrypted)
Comparison: AES vs RSA
Feature AES (Symmetric) RSA (Asymmetric)
Key Type Single secret key Public & Private keys
Speed Faster Slower
Security Strong but vulnerable if key is
exposed
More secure but computationally expensive
Use
Cases
Encrypting files, Wi-Fi security,
VPNs
Digital signatures, key exchange, secure
emails

More Related Content

PPTX
encryption and decryption ,and its types
PPT
PDF
Chapter 8 cryptography lanjutan
PPT
Elementry Cryptography
PDF
An Understanding And Perspectives of END TO END ENCRYPTION (4).pdf
PPT
cryptography and encryption and decryption
PPT
crypto22222222222222222222222222222222222222222222.ppt
PPTX
Cryptography
encryption and decryption ,and its types
Chapter 8 cryptography lanjutan
Elementry Cryptography
An Understanding And Perspectives of END TO END ENCRYPTION (4).pdf
cryptography and encryption and decryption
crypto22222222222222222222222222222222222222222222.ppt
Cryptography

Similar to UNIT 3.2 Classical and Modern Encryption Techniques.pdf (20)

PPTX
Cryptography
PPTX
619cb9e9-b273-4ed7-9181-937ba84734ab-.pptx
PDF
international security system data threats
PDF
PRINCIPLES OF INFORMATION SYSTEM SECURITY
PPTX
Cryptography 101
PPTX
Cryptography and network security
PPTX
Cryptography
PPTX
Cryptography in discrete structure .pptx
PPTX
Security - ch3.pptx
ODP
Encryption basics
PPTX
Rsa Crptosystem
PPTX
Unit 7 : Network Security
PDF
Public-Key Cryptography.pdfWrite the result of the following operation with t...
PDF
Implementation of aes and blowfish algorithm
PPTX
Rivest Shamir Adleman Algorithm and its variant : DRSA.pptx
PPTX
Cryptography
PPTX
Security - ch3.pptx
PDF
Common Crypto Pitfalls
PDF
CRYPTOGRAPHY (2).pdf
PDF
Basic Cryptography.pdf
Cryptography
619cb9e9-b273-4ed7-9181-937ba84734ab-.pptx
international security system data threats
PRINCIPLES OF INFORMATION SYSTEM SECURITY
Cryptography 101
Cryptography and network security
Cryptography
Cryptography in discrete structure .pptx
Security - ch3.pptx
Encryption basics
Rsa Crptosystem
Unit 7 : Network Security
Public-Key Cryptography.pdfWrite the result of the following operation with t...
Implementation of aes and blowfish algorithm
Rivest Shamir Adleman Algorithm and its variant : DRSA.pptx
Cryptography
Security - ch3.pptx
Common Crypto Pitfalls
CRYPTOGRAPHY (2).pdf
Basic Cryptography.pdf
Ad

More from ChatanBawankar (20)

PDF
Unit 6 Message Digest Message Digest Message Digest
PDF
Unit 4 Legal Issues in Reverse Engineering.pdf
PDF
Unit 4 Reverse Engineering Tools Functionalities & Use-Cases.pdf
PDF
Unit 3 Significance of Log File Analysis in Pentesting.pdf
PDF
Unit 3 Android Permission Model.pdf Android Permission Model
PDF
Unit 3 Android Manifest File.pdf Android Manifest File
PDF
Unit 2 DNS Spoofing in a BadUSB Attack.pdf
PDF
Unit 2 ARP Poisoning Attack ARP Poisoning Attack.
PDF
Unit Kali NetHunter is the official Kali Linux penetration testing platform f...
PDF
Unit 1 Tools Beneficial for Monitoring the Debugging Process.pdf
PDF
Unit 1 Kali NetHunter is the official Kali Linux penetration testing platform...
PDF
Unit 3 Pentesting Analyze log file and find the secret information using Logcat
PDF
Unit 2 Man-In-Middle Attack, Bad USB with MIMA
PDF
Unit 1 Kali Nethunter Android: OS, Debub Bridge
PDF
Unit 1.2 Introduction to Cybercrimes and Their Classification.pdf
PDF
Unit 1.1 Introduction to Cybercrimes and Their Classification.pdf
PDF
Unit 2.3 Introduction to Cyber Security Tools and Environment.pdf
PDF
Unit 2.1 Introduction to Cyber Security Tools and Environment.pdf
DOCX
Unit 2_Crawling a website data collection, search engine indexing, and cybers...
DOCX
Unit 2_Blacklisting & Whitelisting User Input in Python.docx
Unit 6 Message Digest Message Digest Message Digest
Unit 4 Legal Issues in Reverse Engineering.pdf
Unit 4 Reverse Engineering Tools Functionalities & Use-Cases.pdf
Unit 3 Significance of Log File Analysis in Pentesting.pdf
Unit 3 Android Permission Model.pdf Android Permission Model
Unit 3 Android Manifest File.pdf Android Manifest File
Unit 2 DNS Spoofing in a BadUSB Attack.pdf
Unit 2 ARP Poisoning Attack ARP Poisoning Attack.
Unit Kali NetHunter is the official Kali Linux penetration testing platform f...
Unit 1 Tools Beneficial for Monitoring the Debugging Process.pdf
Unit 1 Kali NetHunter is the official Kali Linux penetration testing platform...
Unit 3 Pentesting Analyze log file and find the secret information using Logcat
Unit 2 Man-In-Middle Attack, Bad USB with MIMA
Unit 1 Kali Nethunter Android: OS, Debub Bridge
Unit 1.2 Introduction to Cybercrimes and Their Classification.pdf
Unit 1.1 Introduction to Cybercrimes and Their Classification.pdf
Unit 2.3 Introduction to Cyber Security Tools and Environment.pdf
Unit 2.1 Introduction to Cyber Security Tools and Environment.pdf
Unit 2_Crawling a website data collection, search engine indexing, and cybers...
Unit 2_Blacklisting & Whitelisting User Input in Python.docx
Ad

Recently uploaded (20)

PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Pharma ospi slides which help in ospi learning
PDF
RMMM.pdf make it easy to upload and study
PDF
Computing-Curriculum for Schools in Ghana
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
master seminar digital applications in india
PPTX
Institutional Correction lecture only . . .
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Basic Mud Logging Guide for educational purpose
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Complications of Minimal Access Surgery at WLH
PDF
Classroom Observation Tools for Teachers
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Supply Chain Operations Speaking Notes -ICLT Program
2.FourierTransform-ShortQuestionswithAnswers.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Abdominal Access Techniques with Prof. Dr. R K Mishra
Pharma ospi slides which help in ospi learning
RMMM.pdf make it easy to upload and study
Computing-Curriculum for Schools in Ghana
Module 4: Burden of Disease Tutorial Slides S2 2025
master seminar digital applications in india
Institutional Correction lecture only . . .
O7-L3 Supply Chain Operations - ICLT Program
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Basic Mud Logging Guide for educational purpose
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Complications of Minimal Access Surgery at WLH
Classroom Observation Tools for Teachers
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPH.pptx obstetrics and gynecology in nursing
Chapter 2 Heredity, Prenatal Development, and Birth.pdf

UNIT 3.2 Classical and Modern Encryption Techniques.pdf

  • 1. Unit 3: Classical and Modern Encryption Techniques Prepared By : Dr C D Bawankar Unit 3: Classical and Modern Encryption Techniques 2. Modern Encryption Techniques o RC4 Stream Cipher, Symmetric Encryption (AES), Asymmetric Encryption (RSA) Symmetric and Asymmetric Encryption: AES & RSA Encryption is the process of converting plaintext into ciphertext to secure data from unauthorized access. There are two main types of encryption: 1. Symmetric Encryption (Same key for encryption & decryption) 2. Asymmetric Encryption (Different keys for encryption & decryption) 1. Symmetric Encryption - AES (Advanced Encryption Standard) Overview • AES is a block cipher that encrypts data in fixed-size blocks (128-bit). • Uses the same key for encryption and decryption. • Developed by Vincent Rijmen and Joan Daemen and adopted as a standard by NIST in 2001. • AES supports key sizes of 128-bit, 192-bit, and 256-bit. • Faster than asymmetric encryption. • Used in SSL/TLS, Wi-Fi Security (WPA2), and VPNs. AES Algorithm Steps AES operates in multiple rounds (10 for 128-bit key, 12 for 192-bit, 14 for 256-bit): 1. Key Expansion: Generates multiple round keys from the initial key. 2. Initial Round: o AddRoundKey (XOR plaintext with the key) 3. Main Rounds (Repeated): o SubBytes (Byte substitution using an S-box) o ShiftRows (Row-wise shifting of bytes) o MixColumns (Matrix multiplication to mix data) o AddRoundKey 4. Final Round (No MixColumns) o SubBytes o ShiftRows o AddRoundKey Numerical Example of AES (Simplified) Given Data: • Plaintext (16 bytes): "HELLO_WORLD_AES!" (ASCII representation) • Key (16 bytes, 128-bit): "THIS_IS_MY_KEY!!" Convert plaintext & key to binary: H = 01001000 E = 01000101 L = 01001100 L = 01001100 O = 01001111 _ = 01011111 W = 01010111 O = 01001111
  • 2. Unit 3: Classical and Modern Encryption Techniques Prepared By : Dr C D Bawankar R = 01010010 L = 01001100 D = 01000100 _ = 01011111 A = 01000001 E = 01000101 S = 01010011 ! = 00100001 1. 2. AddRoundKey (Initial XOR with key). 3. SubBytes (Byte substitution using S-box). 4. ShiftRows (Rearrange rows). 5. MixColumns (Mathematical transformation). 6. Repeat for 10 rounds (for 128-bit key). 7. Ciphertext Output: Binary converted back to text. Python Program for AES Encryption Using pycryptodome library: from Crypto.Cipher import AES import base64 # Function to pad plaintext to be multiple of 16 bytes def pad(text): return text + (16 - len(text) % 16) * chr(16 - len(text) % 16) # Function to encrypt using AES def aes_encrypt(plain_text, key): cipher = AES.new(key.encode('utf-8'), AES.MODE_ECB) # ECB mode return base64.b64encode(cipher.encrypt(pad(plain_text).encode('utf-8'))).decode('utf-8') # Function to decrypt using AES def aes_decrypt(cipher_text, key): cipher = AES.new(key.encode('utf-8'), AES.MODE_ECB) decrypted = cipher.decrypt(base64.b64decode(cipher_text)).decode('utf-8') return decrypted.rstrip(decrypted[-1]) # Remove padding # Example usage key = "THIS_IS_MY_KEY!!" # 16-byte key plaintext = "HELLO_WORLD_AES!" encrypted = aes_encrypt(plaintext, key) print("Encrypted Text:", encrypted) decrypted = aes_decrypt(encrypted, key) print("Decrypted Text:", decrypted)
  • 3. Unit 3: Classical and Modern Encryption Techniques Prepared By : Dr C D Bawankar 2. Asymmetric Encryption - RSA (Rivest-Shamir-Adleman) Overview • RSA is an asymmetric encryption algorithm that uses two keys: o Public Key (for encryption) o Private Key (for decryption) • Developed by Ron Rivest, Adi Shamir, and Leonard Adleman in 1977. • Used in SSL/TLS, Digital Signatures, and Secure Communications. • Slower than AES but provides stronger security. RSA Algorithm Steps 1. Key Generation: o Choose two large prime numbers p and q. o Compute n = p × q (modulus). o Compute ϕ(n) = (p - 1) × (q - 1) (Euler's totient function). o Choose an encryption exponent e such that 1 < e < ϕ(n) and gcd(e, ϕ(n)) = 1. o Compute decryption exponent d such that (e × d) mod ϕ(n) = 1. o Public Key: (n, e), Private Key: (n, d). 2. Encryption: C=(Pe)mod nC = (P^e) mod nC=(Pe)modn where P is plaintext, C is ciphertext. 3. Decryption: P=(Cd)mod nP = (C^d) mod nP=(Cd)modn using private key (n, d). Numerical Example of RSA Given: • Choose p = 3, q = 11 • Compute n = 3 × 11 = 33 • Compute ϕ(n) = (3 - 1) × (11 - 1) = 2 × 10 = 20 • Choose e = 7 (since gcd(7, 20) = 1) • Compute d such that (7 × d) mod 20 = 1, so d = 3 • Public Key: (n = 33, e = 7), Private Key: (n = 33, d = 3) Encryption:
  • 4. Unit 3: Classical and Modern Encryption Techniques Prepared By : Dr C D Bawankar • Plaintext (P) = 5 • Ciphertext C = (5^7) mod 33 = 78125 mod 33 = 14 Decryption: • P = (C^d) mod n = (14^3) mod 33 = 2744 mod 33 = 5 Decrypted message matches the original plaintext! •
  • 5. Unit 3: Classical and Modern Encryption Techniques Prepared By : Dr C D Bawankar •
  • 6. Unit 3: Classical and Modern Encryption Techniques Prepared By : Dr C D Bawankar Python Program for RSA Using cryptography library: from Crypto.PublicKey import RSA from Crypto.Cipher import PKCS1_OAEP import base64 # Generate RSA key pair key = RSA.generate(1024) public_key = key.publickey().export_key()
  • 7. Unit 3: Classical and Modern Encryption Techniques Prepared By : Dr C D Bawankar private_key = key.export_key() # Encrypt function def rsa_encrypt(plaintext, public_key): recipient_key = RSA.import_key(public_key) cipher_rsa = PKCS1_OAEP.new(recipient_key) encrypted_text = cipher_rsa.encrypt(plaintext.encode()) return base64.b64encode(encrypted_text).decode() # Decrypt function def rsa_decrypt(ciphertext, private_key): private_key = RSA.import_key(private_key) cipher_rsa = PKCS1_OAEP.new(private_key) decrypted_text = cipher_rsa.decrypt(base64.b64decode(ciphertext)) return decrypted_text.decode() # Example usage plaintext = "Hello RSA!" encrypted = rsa_encrypt(plaintext, public_key) print("Encrypted Text:", encrypted) decrypted = rsa_decrypt(encrypted, private_key) print("Decrypted Text:", decrypted) Comparison: AES vs RSA Feature AES (Symmetric) RSA (Asymmetric) Key Type Single secret key Public & Private keys Speed Faster Slower Security Strong but vulnerable if key is exposed More secure but computationally expensive Use Cases Encrypting files, Wi-Fi security, VPNs Digital signatures, key exchange, secure emails