FACULTY OF ENGINEERING AND TECHNOLOGY
COMPUTER SCIENCE & ENGINEERING DEPARTMENT
BACHELOR OF TECHNOLOGY
INFORMATION AND NETWORK SECURITY LABORATORY ( 303105376 )
VII SEMESTER
Session 2025 – 2026
CERTIFICATE
This is to certify that
Mr. Shahil Prasad with enrolment no. 2203051050528
has successfully completed his laboratory experiments in the subject of
INFORMATION AND NETWORK SECURITY LABORATORY ( 303105376 )
from the department of Computer Science and Engineering
during the academic year 2025 – 2026
Date of Submission : ......................... Staff In charge : ..........................
Head Of Department : ...........................................
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
TABLE OF CONTENT
Page No
Sr. Date of Date of Marks
Experiment Title Sign
No. Start Completion
From To
1 Implement Caesar cipher encryption
Decryption
2 Implement Monoalphabetic cipher
encryption-decryption
3 Implement Playfair cipher encryption-
Decryption
4 Implement Polyalphabetic cipher
encryption-decryption
5 Implement Hill cipher encryption-
Decryption
6 Implement Simple Transposition
encryption-decryption
7 Implement One time pad encryption-
Decryption
8 Implement Diffie-Hellmen Key
exchange
Method
9 Implement RSA encryption-decryption
Algorithm
10 Demonstrate working of Digital
Signature
using Cryptool
Enrollment No:- 2203051050528 1
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
Practical - 1
Aim :- Implement Caesar Cipher Encryption Decryption.
Description :-
This project implements the Caesar Cipher, a classic encryption technique where each letter in the
text is shifted by a fixed number of positions in the alphabet. It supports both encryption and
decryption using a key (shift value), while preserving non-alphabetic characters. This simple yet
powerful cipher helps demonstrate the basics of cryptography and character manipulation.
Overview & Explanation :-
The Caesar Cipher is one of the simplest and oldest methods of encrypting messages, named
after Julius Caesar, who reportedly used it to protect his military communications. This technique
involves shifting the letters of the alphabet by a fixed number of places. For example, with a shift of
three, the letter 'A' becomes 'D', 'B' becomes 'E', and so on. Despite its simplicity, the Caesar Cipher
formed the groundwork for modern cryptographic techniques.
What is Caesar Cipher Technique?
The Caesar cipher is a simple encryption technique that was used by Julius Caesar to send secret
messages to his allies. It works by shifting the letters in the plaintext message by a certain number
of positions, known as the "shift" or "key".
Steps to Perform Caesar Cipher :-
1. Choose a shift value between 1 and 25 (this is your encryption key).
2. Write down the alphabet in order from A to Z:
AB C D E FG H IJ K LM N O PQ RSTUVWXYZ
3. Create a new shifted alphabet by moving each letter forward by the shift value.
For example, if the shift is 3:
Shifted Alphabet:
D E FG H IJ K LM N O PQ RSTUVWXYZAB C
4. Replace each letter in the plaintext with its corresponding letter from the shifted alphabet.
Example:
Plaintext : HELLO
Encrypted : KHOOR
5. To decrypt the message, shift each letter back by the same key value.
Example:
Encrypted : KHOOR
Decrypted : HELLO
Enrollment No:- 2203051050528 2
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
Encryption Formula :-
E(x) = (x + n) mod 26
Where:
• x is the position of the character
• n is the key
Decryption Formula :-
D(x) = (x - n + 26) mod 26
Example :-
Text : ABCDEFGHIJKLMNOPQRSTUVWXYZ
Shift: 23
Cipher: XYZABCDEFGHIJKLMNOPQRSTUVW
Text : ATTACKATONCE
Shift: 4
Cipher: EXXEGOEXSRGI
Numerical Example :-
Plaintext : AB
Shift Key : 2
Step 1: Convert to numbers
A→0
B→1
Step 2: Encryption (E(x) = (x + key) mod 26)
A → (0 + 2) mod 26 = 2 → C
B → (1 + 2) mod 26 = 3 → D
Encrypted Text: CD
Step 3: Decryption (D(x) = (x - key + 26) mod 26)
C → 2 → (2 - 2 + 26) mod 26 = 26 mod 26 = 0 → A
D → 3 → (3 - 2 + 26) mod 26 = 27 mod 26 = 1 → B
Decrypted Text: AB
Enrollment No:- 2203051050528 3
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
Code :-
//A Java Program to illustrate Caesar Cipher Technique
class CaesarCipher
{
// Encrypts text using a shift of s
public static StringBuffer encrypt(String text, int s)
{
StringBuffer result= new StringBuffer();
for (int i=0; i<text.length(); i++)
{
if (Character.isUpperCase(text.charAt(i)))
{
char ch = (char)(((int)text.charAt(i) +
s - 65) % 26 + 65);
result.append(ch);
}
else
{
char ch = (char)(((int)text.charAt(i) +
s - 97) % 26 + 97);
result.append(ch);
}
}
return result;
}
// Driver code
public static void main(String[] args)
{
String text = "ATTACKATONCE";
int s = 4;
System.out.println("Text : " + text);
System.out.println("Shift : " + s);
System.out.println("Cipher: " + encrypt(text, s));
}
}
Enrollment No:- 2203051050528 4
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
Output :-
Conclusion :-
We have successfully implemented Caesar Cipher encryption and decryption using basic shift logic
and modular arithmetic.
Enrollment No:- 2203051050528 5
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
Practical - 2
Aim :- Implement Monoalphabetic cipher Encryption-Decryption.
Description :-
The mono-alphabetic cipher is a classical type of substitution cipher in which each letter of the
plaintext is replaced by a unique corresponding letter of the cipher alphabet. Unlike Caesar cipher
which uses a uniform shift, mono-alphabetic ciphers use a randomized or fixed substitution mapping,
making it more secure than simple shift ciphers. It provides a basic understanding of how substitution
encryption works and how frequency analysis can be used to attack such systems.
Overview & Explanation :-
A mono-alphabetic cipher maps each letter of the plaintext to a fixed different letter in the cipher-
text alphabet. This mapping remains the same throughout the message. For example, if ‘A’ is replaced
by ‘Q’, it will always be replaced by ‘Q’ wherever it appears.
Steps to Perform Monoalphabetic Cipher Encryption-Decryption :-
1. Choose or generate a substitution key:
• This is typically a permutation of the 26 English alphabets.
• Example :-
Plain 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
Cipher Alphabet: Q W E R T Y U I O P A S D F G H J K L Z X C V B N M
2. Encryption:
• Replace each letter in the plaintext with its corresponding letter in the cipher alphabet.
• Non-alphabet characters (digits, punctuation) remain unchanged.
3. Decryption:
• Replace each letter in the ciphertext with its corresponding letter from the inverse mapping (cipher
→ plain).
4. Print or store the final encrypted and decrypted text.
How Does Monoalphabetic Cipher Work?
In a monoalphabetic cipher, each letter in the plaintext is replaced
by a corresponding letter from a fixed, randomly mapped cipher alphabet.
This mapping does not follow a uniform shift (like in Caesar cipher)
but instead is arbitrarily chosen.
Below is a conceptual mapping table:
—————————————————————————————-
| 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: Q W E R T Y S U I O P A D F G H J K L Z X C V B N M. |
—————————————————————————————-
Enrollment No:- 2203051050528 6
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
Example :-
Input (Plain-text): GFG
Step-by-step mapping:
- G -> S
- F -> R
- G -> S (same mapping used consistently)
Output (Cipher-text): SRS
Explanation:
The substitution is based on the fixed mapping above,
not on arithmetic differences. Each occurrence of G
is always replaced by S, and F by R.
Types of Monoalphabetic Ciphers :-
1. Simple Substitution Cipher
- Each plaintext letter is replaced by a fixed different letter.
- Example: Caesar Cipher is a special case with a uniform shift.
2. Keyword Cipher
- Uses a keyword to rearrange the alphabet.
- Remaining letters are filled after the keyword without repetition.
- Example:
Keyword = 'KEY'
Mapping = K E Y A B C D F G H I J L M N O P Q R S T U V W X Z
3. Playfair Cipher
- Encrypts pairs (digraphs) of letters using a 5x5 matrix of letters based on a keyword.
- Not strictly single letter substitution, but still mono-alphabetic per digraph.
4. Homophonic Substitution Cipher
- Maps each plaintext letter to one of several possible cipher symbols to disguise frequency.
5. Poly-alphabetic vs Mono-alphabetic
- Monoalphabetic uses **one fixed substitution alphabet** for the whole message.
- In contrast, poly-alphabetic ciphers (like Vigenère) use multiple cipher alphabets.
Note:
- Mono-alphabetic generally means one mapping used throughout, regardless of how that mapping
is derived (shift, keyword, arbitrary random, or table-based).
Enrollment No:- 2203051050528 7
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
Code :-
// Java Program to Implement the Monoalphabetic Cypher
import java.io.*;
class GFG {
public static char normalChar[]
= { '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' };
public static char codedChar[]
= { 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O',
'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K',
'L', 'Z', 'X', 'C', 'V', 'B', 'N', 'M' };
// Function which returns encrypted string
public static String stringEncryption(String s)
{
// initializing an empty String
String encryptedString = "";
// comparing each character of the string and
// encoding each character using the indices
for (int i = 0; i < s.length(); i++) {
for (int j = 0; j < 26; j++) {
// comparing the character and
// adding the corresponding char
// to the encryptedString
if (s.charAt(i) == normalChar[j])
{
encryptedString += codedChar[j];
break;
}
// if there are any special characters
// add them directly to the string
if (s.charAt(i) < 'a' || s.charAt(i) > 'z')
{
encryptedString += s.charAt(i);
break;
}
}
}
Enrollment No:- 2203051050528 8
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
// return encryptedString
return encryptedString;
}
// Function which returns descryptedString
public static String stringDecryption(String s)
{
// Initializing the string
String decryptedString = "";
// Run the for loop for total string
for (int i = 0; i < s.length(); i++)
{
for (int j = 0; j < 26; j++) {
// compare each characters and decode them
// using indices
if (s.charAt(i) == codedChar[j])
{
decryptedString += normalChar[j];
break;
}
// Add the special characters directly to
// the String
if (s.charAt(i) < 'A' || s.charAt(i) > 'Z')
{
decryptedString += s.charAt(i);
break;
}
}
}
// return the decryptedString
return decryptedString;
}
public static void main(String args[])
{
String str = "Welcome to geeksforgeeks";
// print plain text
System.out.println("Plain text: " + str);
// Changing whole string to lower case
// function call to stringEncryption and storing in
Enrollment No:- 2203051050528 9
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
// encryptedString
String encryptedString = stringEncryption(str.toLowerCase());
// printing encryptedString
System.out.println("Encrypted message: "
+ encryptedString);
// function call to stringDecryption and printing
// the decryptedString
System.out.println("Decrypted message: "
+ stringDecryption(encryptedString));
}
}
Output :-
Conclusion :-
We have successfully implemented Mono-alphabetic Cipher using fixed letter substitution.
Enrollment No:- 2203051050528 10
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
Practical - 3
Aim :- Implement Playfair cipher Encryption-Decryption.
Description :-
The Play-fair Cipher is a digraph substitution cipher that encrypts pairs of letters (digraphs), instead
of single letters as in simple substitution ciphers. It uses a 5x5 matrix constructed using a keyword,
omitting the letter ‘J’ to fit the 25-letter alphabet. This cipher improves security over monoalphabetic
methods by obscuring letter frequency and introducing position-based transformations. It
demonstrates a practical, real-world historical cryptographic technique used in military
communication.
Overview & Explanation :-
Developed by Charles Wheatstone in 1854, the Playfair Cipher was popularized by Lord Playfair and
used during World War I and II. It encrypts plaintext in pairs of letters using rules based on their
positions within a 5x5 matrix derived from a keyword.
Matrix Creation Rules:
1. Choose a keyword (e.g., MONARCHY) and fill in the matrix from left to right, top to
bottom.
2. Remove duplicate letters in the keyword.
3. Fill the remaining spaces in the matrix with the rest of the alphabet (excluding ‘J’).
Example (keyword = MONARCHY):
MONAR
CHYBD
EFGIK
LPQST
UVWXZ
Rules for Encryption:
1. Preprocessing:
• Replace ‘J’ with ‘I’ in plaintext.
• Break the plaintext into digraphs (pairs of letters).
• If both letters in a pair are the same, insert ‘X’ between them.
2. Encryption Rules:
• Same row: Replace each letter with the letter to its immediate right (wrap around if
needed).
• Same column: Replace each letter with the letter immediately below it (wrap around).
• Rectangle (different row & column): Replace each letter with the letter in the same
row but in the column of the other letter.
Enrollment No:- 2203051050528 11
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
Rules for Decryption:
Same as encryption but:
• For same row, move left.
• For same column, move up.
• For rectangle, same logic.
Example:
Plaintext: HELLO
→ Convert to digraphs: HE LX LO
→ Matrix mapping (using above example matrix)
Encrypted Text: DM RC RN
Code :-
import java.util.*;
public class Main {
static char[][] matrix = new char[5][5];
static Map<Character, int[]> positionMap = new HashMap<>();
// Build 5x5 key matrix
static void generateMatrix(String key) {
key = key.toUpperCase().replace("J", "I");
Set<Character> used = new LinkedHashSet<>();
for (char c : key.toCharArray()) {
if (Character.isLetter(c)) used.add(c);
}
for (char c = 'A'; c <= 'Z'; c++) {
if (c != 'J') used.add(c);
}
Iterator<Character> it = used.iterator();
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
char ch = it.next();
matrix[i][j] = ch;
positionMap.put(ch, new int[]{i, j});
}
}
}
Enrollment No:- 2203051050528 12
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
// Format input into digraphs
static List<String> prepareDigraphs(String text) {
text = text.toUpperCase().replaceAll("[^A-Z]", "").replace("J", "I");
List<String> digraphs = new ArrayList<>();
int i = 0;
while (i < text.length()) {
char a = text.charAt(i++);
char b = (i < text.length()) ? text.charAt(i) : 'X';
if (a == b) {
digraphs.add("" + a + 'X');
} else {
digraphs.add("" + a + b);
i++;
}
}
// If last digraph has one letter, pad with X
if (!digraphs.isEmpty() && digraphs.get(digraphs.size() - 1).length() == 1) {
digraphs.set(digraphs.size() - 1, digraphs.get(digraphs.size() - 1) + "X");
}
return digraphs;
}
// Encrypt a pair
static String encryptPair(char a, char b) {
int[] pos1 = positionMap.get(a);
int[] pos2 = positionMap.get(b);
if (pos1[0] == pos2[0]) {
return "" + matrix[pos1[0]][(pos1[1] + 1) % 5] + matrix[pos2[0]][(pos2[1] + 1) % 5];
} else if (pos1[1] == pos2[1]) {
return "" + matrix[(pos1[0] + 1) % 5][pos1[1]] + matrix[(pos2[0] + 1) % 5][pos2[1]];
} else {
return "" + matrix[pos1[0]][pos2[1]] + matrix[pos2[0]][pos1[1]];
}
}
// Decrypt a pair
static String decryptPair(char a, char b) {
int[] pos1 = positionMap.get(a);
int[] pos2 = positionMap.get(b);
Enrollment No:- 2203051050528 13
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
if (pos1[0] == pos2[0]) {
return "" + matrix[pos1[0]][(pos1[1] + 4) % 5] + matrix[pos2[0]][(pos2[1] + 4) % 5];
} else if (pos1[1] == pos2[1]) {
return "" + matrix[(pos1[0] + 4) % 5][pos1[1]] + matrix[(pos2[0] + 4) % 5][pos2[1]];
} else {
return "" + matrix[pos1[0]][pos2[1]] + matrix[pos2[0]][pos1[1]];
}
}
// Encrypt full text
static String encrypt(String text) {
List<String> digraphs = prepareDigraphs(text);
StringBuilder result = new StringBuilder();
for (String pair : digraphs) {
result.append(encryptPair(pair.charAt(0), pair.charAt(1)));
}
return result.toString();
}
// Decrypt full text
static String decrypt(String text) {
List<String> digraphs = prepareDigraphs(text);
StringBuilder result = new StringBuilder();
for (String pair : digraphs) {
result.append(decryptPair(pair.charAt(0), pair.charAt(1)));
}
return result.toString();
}
// Display matrix
static void printMatrix() {
System.out.println("Playfair Matrix:");
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
System.out.print(matrix[i][j] + " ");
}
System.out.println();
}
}
// Main function
public static void main(String[] args) {
// Hardcoded inputs (safe for online compiler)
String keyword = "MONARCHY";
Enrollment No:- 2203051050528 14
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
String plaintext = "HELLO";
generateMatrix(keyword);
printMatrix();
System.out.println("Keyword : " + keyword);
System.out.println("Plaintext : " + plaintext);
String encrypted = encrypt(plaintext);
System.out.println("Encrypted : " + encrypted);
String decrypted = decrypt(encrypted);
System.out.println("Decrypted : " + decrypted);
}
}
Output :-
Conclusion :-
We have successfully implemented the Playfair Cipher for encryption and decryption
Enrollment No:- 2203051050528 15
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
Practical - 4
Aim :- Implement Poly-Alphabetic Cipher (Vigenère Cipher) Encryption-Decryption.
Description :-
The Poly-Alphabetic Cipher is an encryption technique that uses multiple Caesar ciphers in
sequence based on the letters of a keyword. The most famous version is the Vigenère Cipher, which
shifts each letter of the plaintext by a variable amount determined by a repeating keyword. This
method significantly increases security by obscuring letter frequency and reducing pattern
predictability.
Overview & Explanation :-
Unlike monoalphabetic ciphers that use a fixed substitution throughout the message, the
polyalphabetic cipher shifts each letter by different amounts depending on a keyword. This makes
the cipher more resistant to frequency analysis and brute force attacks.
How It Works:
1. Choose a keyword. Repeat it to match the length of the plaintext.
2. Convert each character of the keyword and the plaintext into its corresponding position (A=0,
B=1, …, Z=25).
3. Encrypt by shifting each plaintext character forward by the corresponding keyword letter.
4. Decrypt by shifting backwards using the same keyword.
Steps to Perform Polyalphabetic Cipher Encryption-Decryption :-
Encryption Formula: E(i) = (P(i) + K(i)) mod 26
Decryption Formula: D(i) = (C(i) - K(i) + 26) mod 26
Where:
• P(i) is the ith character of plaintext (as a number)
• K(i) is the ith character of repeated keyword
• C(i) is the ith character of ciphertext
Example :-
Plaintext: HELLO
Keyword : KEY
Repeated Keyword: KEYKE
Conversion (A=0…Z=25):
SEE NEXT PAGE
Enrollment No:- 2203051050528 16
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
Encrypted Output: RIJVS
Decrypted Output: HELLO
Code :-
public class Main {
// Repeat the key to match length of text
public static String generateKey(String text, String key) {
key = key.toUpperCase();
StringBuilder result = new StringBuilder();
int x = 0;
for (int i = 0; i < text.length(); i++) {
if (Character.isLetter(text.charAt(i))) {
result.append(key.charAt(x));
x = (x + 1) % key.length();
} else {
result.append(text.charAt(i)); // Preserve space/punctuation
}
}
return result.toString();
}
// Encrypt using Vigenère Cipher
public static String encrypt(String plaintext, String keyword) {
plaintext = plaintext.toUpperCase();
keyword = generateKey(plaintext, keyword);
StringBuilder cipherText = new StringBuilder();
for (int i = 0; i < plaintext.length(); i++) {
char pt = plaintext.charAt(i);
char key = keyword.charAt(i);
if (Character.isLetter(pt)) {
char enc = (char) (((pt - 'A') + (key - 'A')) % 26 + 'A');
cipherText.append(enc);
} else {
cipherText.append(pt); // Non-alphabet characters unchanged
}
Enrollment No:- 2203051050528 17
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
}
return cipherText.toString();
}
// Decrypt using Vigenère Cipher
public static String decrypt(String cipherText, String keyword) {
cipherText = cipherText.toUpperCase();
keyword = generateKey(cipherText, keyword);
StringBuilder originalText = new StringBuilder();
for (int i = 0; i < cipherText.length(); i++) {
char ct = cipherText.charAt(i);
char key = keyword.charAt(i);
if (Character.isLetter(ct)) {
char dec = (char) (((ct - key + 26) % 26) + 'A');
originalText.append(dec);
} else {
originalText.append(ct); // Non-alphabet characters unchanged
}
}
return originalText.toString();
}
// Main function
public static void main(String[] args) {
// Hardcoded input for online compiler compatibility
String plaintext = "HELLO WORLD";
String keyword = "KEY";
// Encrypt and Decrypt
String encrypted = encrypt(plaintext, keyword);
String decrypted = decrypt(encrypted, keyword);
// Output
System.out.println("Plaintext : " + plaintext);
System.out.println("Keyword : " + keyword);
System.out.println("Encrypted : " + encrypted);
System.out.println("Decrypted : " + decrypted);
}
}
Enrollment No:- 2203051050528 18
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
Output :-
Conclusion :-
We have successfully implemented the Poly-alphabetic Cipher (Vigenère Cipher) using keyword-
based character shifting.
Enrollment No:- 2203051050528 19
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
Practical - 5
Aim :- Implementation of Hill Cipher – Encryption and Decryption
Description :-
Hill cipher is a symmetric polygraphic substitution cipher based on linear algebra. It encrypts
plaintext in blocks (like pairs or triplets) using matrix multiplication. The key is a square matrix,
and the plaintext is represented as vectors of numerical values. It’s more secure than mono-
alphabetic ciphers due to its use of matrix operations and block-wise substitution.
Overview & Explanation :-
Hill cipher is a symmetric polygraphic substitution cipher based on linear algebra. It encrypts
plaintext in blocks (like pairs or triplets) using matrix multiplication. The key is a square matrix,
and the plaintext is represented as vectors of numerical values. It’s more secure than mono-
alphabetic ciphers due to its use of matrix operations and block-wise substitution.
How It Works:
1. Choose the block size (usually 2 or 3 letters at a time).
2. Select an invertible key matrix (n×n) with integer values between 0–25.
3. Convert plaintext into vectors using A=0, B=1, …, Z=25.
4. Encrypt using matrix multiplication:
C = (K × P) mod 26
where K = key matrix, P = plaintext vector, C = ciphertext vector.
5. Decrypt using inverse of key matrix:
P = (K⁻¹ × C) mod 26
6. Convert numerical values back to letters.
Formulas :-
Encryption Formula: C = (K × P) mod 26, where C = cipher-text vector.
Decryption Formula: P = (K⁻¹ × C) mod 26, where K⁻¹ = modular inverse of key matrix.
Example :-
Let’s use a 2×2 key matrix:
Key matrix K = | 3 3 |
|2 5|
Plaintext: HI → H=7, I=8
P= |7|
|8|
Enrollment No:- 2203051050528 20
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
Now, multiply:
C = K × P = | 3 3 | × | 7 | = | (3×7 + 3×8) | = | 21 + 24 | = | 45 |
| 2 5 | | 8 | | (2×7 + 5×8) | | 14 + 40 | | 54 |
Take mod 26:
C = | 45 % 26 | = 19 → T
| 54 % 26 | = 2 → C
Encrypted Text: TC
Numerical Example :-
Plaintext : HI
H → 7, I → 8
Key Matrix:
|33|
|25|
Multiply:
C1 = (3×7 + 3×8) = 45 → 45 mod 26 = 19 → T
C2 = (2×7 + 5×8) = 54 → 54 mod 26 = 2 → C
Ciphertext : TC
Code :-
import java.util.Scanner;
public class HillCipher {
static int[][] key = { {3, 3}, {2, 5} };
// Convert letter to number (A=0 to Z=25)
static int charToNum(char c) {
return c - 'A';
}
// Convert number to letter
static char numToChar(int n) {
return (char) ((n % 26) + 'A');
}
// Multiply key matrix with vector and apply mod 26
static char[] encryptPair(char a, char b) {
Enrollment No:- 2203051050528 21
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
int[] p = { charToNum(a), charToNum(b) };
char[] c = new char[2];
c[0] = numToChar((key[0][0] * p[0] + key[0][1] * p[1]) % 26);
c[1] = numToChar((key[1][0] * p[0] + key[1][1] * p[1]) % 26);
return c;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter 2-letter plaintext (uppercase only): ");
String text = sc.nextLine();
if (text.length() != 2) {
System.out.println("Only 2-letter block supported in this example.");
return;
}
char[] encrypted = encryptPair(text.charAt(0), text.charAt(1));
System.out.println("Encrypted Text: " + new String(encrypted));
// Manual decryption can be implemented using inverse matrix if required
}
}
Output :-
Conclusion :-
We have successfully implemented Hill Cipher encryption using matrix multiplication and modulo
operations, demonstrating secure block-wise substitution.
Enrollment No:- 2203051050528 22
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
Practical - 6
Aim :- Implementation of Simple Transposition Cipher – Encryption and Decryption
Description :-
The Simple Transposition Cipher is a classical cipher that encrypts plaintext by rearranging the
order of characters based on a fixed key. It does not change the characters themselves, only their
positions. This type of cipher is also known as a permutation cipher.
Overview & Explanation :-
In a transposition cipher, the original letters of the plaintext are reordered according to a pattern.
The most basic form uses a fixed key that specifies how characters in the plaintext are permuted.
The message is usually written in a matrix row by row and read column by column (or vice versa)
to get the encrypted message. Since the letters are not altered, only scrambled, this cipher is simple
but still provides a layer of security through obfuscation.
How It Works:
1. Choose a key (a numeric value representing the number of columns).
2. Write the plaintext in rows under the number of columns.
3. Fill any remaining blank with padding (e.g., ‘X’) if the length is not a multiple of the key.
4. Read the matrix column-wise (top to bottom, left to right) to generate the ciphertext.
5. To decrypt, rebuild the matrix using the key and read row-wise.
Formula:
There’s no mathematical formula like modular arithmetic here. It’s based on matrix rearrangement
using a fixed pattern (key):
• Encryption: Rearrange letters column-wise from a grid
• Decryption: Reconstruct grid column-wise and read row-wise
Example:
Plaintext: ATTACKATDAWN
Key (columns): 4
Step 1: Arrange text in 4 columns (fill rows left to right)
A T T A
C K A T
D A W N
Step 2: Read column-wise to encrypt:
Col 1: A C D
Col 2: T K A
Enrollment No:- 2203051050528 23
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
Col 3: T A W
Col 4: A T N
Encrypted Text: ACDTKATAWATN → ACDTKATAWATN
Numerical Example:
Plaintext: HELLO
Key: 2 (2 columns)
Step 1:
H E
L L
O X (X is padding)
Step 2:
Read columns: HLOELX
Encrypted Text: HLOELX
Code :-
import java.util.Scanner;
public class TranspositionCipher {
// Encrypt using simple transposition cipher
public static String encrypt(String text, int key) {
int rows = (int) Math.ceil((double) text.length() / key);
char[][] grid = new char[rows][key];
int k = 0;
// Fill the grid row-wise
for (int i = 0; i < rows; i++) {
for (int j = 0; j < key; j++) {
if (k < text.length()) {
grid[i][j] = text.charAt(k++);
} else {
grid[i][j] = 'X'; // Padding
}
}
}
// Read grid column-wise
StringBuilder cipher = new StringBuilder();
for (int j = 0; j < key; j++) {
Enrollment No:- 2203051050528 24
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
for (int i = 0; i < rows; i++) {
cipher.append(grid[i][j]);
}
}
return cipher.toString();
}
// Decrypt using transposition cipher
public static String decrypt(String cipher, int key) {
int rows = (int) Math.ceil((double) cipher.length() / key);
char[][] grid = new char[rows][key];
int k = 0;
// Fill the grid column-wise
for (int j = 0; j < key; j++) {
for (int i = 0; i < rows; i++) {
if (k < cipher.length()) {
grid[i][j] = cipher.charAt(k++);
}
}
}
// Read the grid row-wise
StringBuilder plain = new StringBuilder();
for (int i = 0; i < rows; i++) {
for (int j = 0; j < key; j++) {
plain.append(grid[i][j]);
}
}
return plain.toString();
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter message: ");
String message = sc.nextLine().replaceAll("\\s", "").toUpperCase();
System.out.print("Enter key (number of columns): ");
int key = sc.nextInt();
String encrypted = encrypt(message, key);
System.out.println("Encrypted Text: " + encrypted);
Enrollment No:- 2203051050528 25
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
String decrypted = decrypt(encrypted, key);
System.out.println("Decrypted Text: " + decrypted);
}
}
Output :-
Conclusion:
We have successfully implemented the Simple Transposition Cipher using matrix-based
rearrangement of characters for both encryption and decryption.
Enrollment No:- 2203051050528 26
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
Practical - 7
Aim :- Implementation of Simple Transposition Cipher – Encryption and Decryption
Description :-
The One-Time Pad (OTP) is a perfectly secure symmetric encryption technique where each
character of the plaintext is encrypted using a random key character of the same length. The key is
used only once and then discarded, ensuring unbreakable security when used correctly.
Overview & Explanation :-
The One-Time Pad operates by combining each character of the plaintext with a corresponding
character from a randomly generated key of the same length. This combination is done using
bitwise XOR (in binary form) or modular addition (mod 26) for alphabetic characters.
For the OTP to be truly secure:
• The key must be completely random
• It must be as long as the message
• It must be used only once
• It must be kept completely secret
If these conditions are met, OTP is theoretically unbreakable.
How It Works :-
1. Generate a random key that is the same length as the plaintext.
2. Convert both plaintext and key into numbers (A=0, …, Z=25).
3. Encrypt using:
Ci = (Pi + Ki) mod 26
4. Decrypt using:
Pi = (Ci - Ki + 26) mod 26
5. Convert numeric result back to characters.
Formula:
Encryption: Ci = (Pi + Ki) mod 26
Decryption: Pi = (Ci - Ki + 26) mod 26
Where:
• Pi = ith plaintext letter (as number)
• Ki = ith key letter (as number)
• Ci = ith cipher letter (as number)
Enrollment No:- 2203051050528 27
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
Example:
Plaintext : HELLO
Key : XMCKL (random)
Step-by-step:
H = 7, X = 23 → (7 + 23) mod 26 = 30 mod 26 = 4 → E
E = 4, M = 12 → (4 + 12) mod 26 = 16 → Q
L = 11, C = 2 → (11 + 2) = 13 → N
L = 11, K = 10 → (11 + 10) = 21 → V
O = 14, L = 11 → (14 + 11) = 25 → Z
Encrypted: EQNVZ
Decryption:
E = 4, X = 23 → (4 - 23 + 26) mod 26 = 7 → H
... and so on → HELLO
Numerical Example:
Plaintext : AB
Key : CD
A=0, C=2 → (0+2)%26 = 2 → C
B=1, D=3 → (1+3)%26 = 4 → E
Encrypted : CE
Decryption:
C=2, C=2 → (2-2+26)%26 = 0 → A
E=4, D=3 → (4-3+26)%26 = 1 → B
Decrypted : AB
Code :-
import java.util.*;
public class OneTimePadCipher {
// Convert character to number (A=0 to Z=25)
static int charToNum(char c) {
return c - 'A';
}
// Convert number to character (0 to 25 = A to Z)
Enrollment No:- 2203051050528 28
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
static char numToChar(int n) {
return (char) ((n % 26) + 'A');
}
// Generate a random key of same length
static String generateRandomKey(int length) {
Random rand = new Random();
StringBuilder key = new StringBuilder();
for (int i = 0; i < length; i++) {
char randomChar = (char) ('A' + rand.nextInt(26));
key.append(randomChar);
}
return key.toString();
}
public static String encrypt(String plaintext, String key) {
StringBuilder cipher = new StringBuilder();
plaintext = plaintext.toUpperCase();
key = key.toUpperCase();
for (int i = 0; i < plaintext.length(); i++) {
int p = charToNum(plaintext.charAt(i));
int k = charToNum(key.charAt(i));
cipher.append(numToChar((p + k) % 26));
}
return cipher.toString();
}
public static String decrypt(String cipherText, String key) {
StringBuilder plain = new StringBuilder();
cipherText = cipherText.toUpperCase();
key = key.toUpperCase();
for (int i = 0; i < cipherText.length(); i++) {
int c = charToNum(cipherText.charAt(i));
int k = charToNum(key.charAt(i));
plain.append(numToChar((c - k + 26) % 26));
}
return plain.toString();
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter plaintext (A-Z only): ");
Enrollment No:- 2203051050528 29
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
String plaintext = sc.nextLine().toUpperCase();
String key = generateRandomKey(plaintext.length());
System.out.println("Generated Key: " + key);
String encrypted = encrypt(plaintext, key);
System.out.println("Encrypted Text: " + encrypted);
String decrypted = decrypt(encrypted, key);
System.out.println("Decrypted Text: " + decrypted);
}
}
Output :-
Conclusion :-
We have successfully implemented the One-Time Pad cipher using randomly generated keys and
modular arithmetic for encryption and decryption.
Enrollment No:- 2203051050528 30
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
Practical - 8
Aim :- Implementation of Diffie-Hellman Key Exchange Method.
Description :-
The Diffie - Hellman Key Exchange algorithm is a fundamental technique used in modern
cryptography to securely share a secret key over an insecure communication channel. This method
allows two parties to establish a shared secret key without directly transmitting it, forming the
foundation for many secure communication protocols.
Overview & Explanation :-
Proposed by Whitfield Diffie and Martin Hellman in 1976, this method uses properties of modular
arithmetic and discrete logarithms to enable key exchange. Each user selects a private key, and
using publicly known base (g) and prime (p), they generate and share public keys.
Using the received public key and their own private key, each party can independently compute the
shared secret, which will be identical for both due to the mathematical properties of exponentiation
modulo a prime.
Note: Diffie-Hellman is not an encryption algorithm. It only establishes a shared key to be used
later for encryption/decryption.
How It Works :-
1. Publicly known values:
• A prime number p
• A primitive root g (base) modulo p
2. Both users generate private keys:
• User A chooses private key a
• User B chooses private key b
3. Compute public keys:
• A sends: A_public = (g^a) mod p
• B sends: B_public = (g^b) mod p
4. Compute shared secret:
• A computes: K = (B_public^a) mod p
• B computes: K = (A_public^b) mod p
Since both compute using the same base and mod, they get the same shared key K.
Formula :-
• Public key A: A = (g^a) mod p
• Public key B: B = (g^b) mod p
• Shared key (A): K = (B^a) mod p
• Shared key (B): K = (A^b) mod p
Enrollment No:- 2203051050528 31
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
Example :-
Publicly known:
p = 23 (prime)
g = 5 (primitive root of 23)
Private keys:
User A chooses a = 6
User B chooses b = 15
Public keys:
A_public = (5^6) mod 23 = 15625 mod 23 = 8
B_public = (5^15) mod 23 = 30517578125 mod 23 = 2
Exchange public keys.
Shared secret key:
A computes: (2^6) mod 23 = 64 mod 23 = 18
B computes: (8^15) mod 23 = large number mod 23 = 18
Shared Key = 18
Code :-
import java.util.Scanner;
public class DiffieHellmanKeyExchange {
// Modular exponentiation function: (base^exp) % mod
static int powerMod(int base, int exp, int mod) {
int result = 1;
base = base % mod;
while (exp > 0) {
if ((exp & 1) == 1)
result = (result * base) % mod;
exp = exp >> 1; // divide exp by 2
base = (base * base) % mod;
}
return result;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("=== Diffie-Hellman Key Exchange ===");
Enrollment No:- 2203051050528 32
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
System.out.print("Enter a prime number (p): ");
int p = sc.nextInt();
System.out.print("Enter primitive root modulo p (g): ");
int g = sc.nextInt();
System.out.print("Enter private key for User A (a): ");
int a = sc.nextInt();
System.out.print("Enter private key for User B (b): ");
int b = sc.nextInt();
// Public keys
int A_public = powerMod(g, a, p);
int B_public = powerMod(g, b, p);
System.out.println("\nUser A's Public Key (g^a mod p): " + A_public);
System.out.println("User B's Public Key (g^b mod p): " + B_public);
// Shared keys
int A_shared = powerMod(B_public, a, p);
int B_shared = powerMod(A_public, b, p);
System.out.println("\nShared Key computed by A: " + A_shared);
System.out.println("Shared Key computed by B: " + B_shared);
if (A_shared == B_shared) {
System.out.println("\n Key Exchange Successful! Shared Key: " + A_shared);
} else {
System.out.println("\n Key Exchange Failed. Shared keys do not match.");
}
sc.close();
}
}
Output :-
SEE IMAGE ON NEXT PAGE
Enrollment No:- 2203051050528 33
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
Conclusion :-
We have successfully implemented the Diffie-Hellman key exchange method using modular
exponentiation to securely generate a shared secret key over an insecure channel.
Enrollment No:- 2203051050528 34
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
Practical - 9
Aim :- Implementation of RSA Encryption and Decryption Algorithm.
Description :-
RSA (Rivest Shamir Adleman) is a widely used asymmetric cryptographic algorithm. It uses two
keys a public key for encryption and a private key for decryption. RSA is based on the mathematical
difficulty of factoring large prime numbers, making it a secure and foundational technique in
modern public-key cryptography.
Overview & Explanation :-
RSA works using modular exponentiation and Euler’s totient function. Two large prime numbers
are selected and multiplied to generate n, which forms the modulus for both keys. An encryption
exponent e (public) and decryption exponent d (private) are then computed such that:
(e × d) mod φ(n) = 1
Where:
• φ(n) = (p-1) × (q-1) is Euler’s totient function
• e is chosen such that 1 < e < φ(n) and gcd(e, φ(n)) = 1
• d is the modular multiplicative inverse of e modulo φ(n)
The public key = (e, n)
The private key = (d, n)
How It Works :-
1. Choose two prime numbers p and q.
2. Compute n = p × q
3. Compute φ(n) = (p - 1)(q - 1)
4. Choose e such that 1 < e < φ(n) and gcd(e, φ(n)) = 1
5. Compute d such that (d × e) mod φ(n) = 1
6. Encrypt: C = (M^e) mod n
7. Decrypt: M = (C^d) mod n
Formula :-
1. Key Generation
• n=p×q
• φ(n) = (p - 1)(q - 1)
• Choose e such that 1 < e < φ(n) and gcd(e, φ(n)) = 1
• Compute d such that:
(d × e) mod φ(n) = 1
2. Encryption
To encrypt a message M:
C = (M^e) mod n
Enrollment No:- 2203051050528 35
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
Where:
• M = plaintext message (in number form)
• C = ciphertext
• e, n = public key
3. Decryption
To decrypt ciphertext C:
M = (C^d) mod n
Where:
• d, n = private key
• M = original message
Example :-
Choose:
p = 3, q = 11
n = 3 × 11 = 33
φ(n) = (3-1)(11-1) = 2 × 10 = 20
Choose e = 7 (gcd(7, 20) = 1)
Compute d: (d × 7) mod 20 = 1 → d = 3 (since 7×3 = 21, 21 mod 20 = 1)
Public key: (e=7, n=33)
Private key: (d=3, n=33)
Message: M = 5
Encryption: C = (5^7) mod 33 = 78125 mod 33 = 14
Decryption: M = (14^3) mod 33 = 2744 mod 33 = 5
Encrypted value: 14
Decrypted value: 5
Code :-
import java.util.Scanner;
public class RSA {
// Method to find GCD
public static int gcd(int a, int b) {
if (b == 0) return a;
return gcd(b, a % b);
}
// Method to find modular inverse of e under mod φ
public static int modInverse(int e, int phi) {
for (int d = 1; d < phi; d++) {
if ((d * e) % phi == 1) return d;
}
Enrollment No:- 2203051050528 36
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
return -1; // No inverse found
}
// Modular exponentiation (base^exp % mod)
public static int modPow(int base, int exp, int mod) {
int result = 1;
base = base % mod;
while (exp > 0) {
if ((exp & 1) == 1)
result = (result * base) % mod;
exp = exp >> 1;
base = (base * base) % mod;
}
return result;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("=== RSA Encryption/Decryption ===");
System.out.print("Enter first prime number (p): ");
int p = sc.nextInt();
System.out.print("Enter second prime number (q): ");
int q = sc.nextInt();
int n = p * q;
int phi = (p - 1) * (q - 1);
System.out.println("Computed n = " + n);
System.out.println("Computed φ(n) = " + phi);
System.out.print("Enter public key exponent (e): ");
int e = sc.nextInt();
if (gcd(e, phi) != 1) {
System.out.println("e is not coprime with φ(n). Choose another e.");
return;
}
int d = modInverse(e, phi);
if (d == -1) {
System.out.println("Modular inverse for e does not exist.");
return;
}
Enrollment No:- 2203051050528 37
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
System.out.println("Private key exponent (d): " + d);
System.out.print("Enter message (integer < " + n + "): ");
int message = sc.nextInt();
int encrypted = modPow(message, e, n);
int decrypted = modPow(encrypted, d, n);
System.out.println("\nEncrypted message: " + encrypted);
System.out.println("Decrypted message: " + decrypted);
}
}
Output :-
Conclusion :-
We have successfully implemented RSA encryption and decryption using modular arithmetic, key
pair generation, and exponentiation to securely encrypt and decrypt a message.
Enrollment No:- 2203051050528 38
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
Practical - 10
Aim :- Demonstrate the working of Digital Signature using Cryptool.
Description :-
A digital signature is a cryptographic mechanism used to validate the authenticity and integrity of a
message or document. It ensures that the message has not been altered and verifies the identity of
the sender. In this experiment, we demonstrate how digital signatures work using CrypTool, a free,
open-source cryptographic simulation software.
Overview & Explanation :-
Digital signatures use asymmetric cryptography, involving a private key (used for signing) and a
public key (used for verifying). The signature is usually generated over a hash of the message and is
encrypted with the sender’s private key.
Key Points:
• Digital signatures ensure:
1. Authentication – verifies sender identity
2. Integrity – ensures message is unaltered
3. Non-repudiation – sender cannot deny having sent the message
• Commonly used algorithms:
• RSA with SHA-256
• DSA (Digital Signature Algorithm)
• ECDSA (Elliptic Curve DSA)
How It Works :-
Pre-requisite: Install CrypTool 1 or CrypTool 2 from https://www.cryptool.org/en
Using CrypTool 1 (CT1) :
1. Launch CrypTool 1
Open the application.
2. Open or Create a Message
Go to File → New, and type your message (e.g., “This is a test message”).
3. Generate Key Pair
• Navigate to Digital Signatures → Generate Keys
• Choose key length (e.g., 1024 bits)
• Save the key pair as required.
4. Sign the Message
• Go to Digital Signatures → Sign Document
• Choose the message file and your private key
• CrypTool will generate the digital signature
5. Verify Signature
• Go to Digital Signatures → Verify Signature
• Provide the original file and signature
• Use the public key for verification
Enrollment No:- 2203051050528 39
Faculty of Engineering and technology
Subject Name: Information and Network Security(INS)
Subject Code: 303105376
B.Tech: 4th Year, SEM: 7th
Using CrypTool 2 (CT2) :
1. Launch CrypTool 2
Select the Visual Workflow Editor.
2. Open Signature Demonstration Template
Go to File → Open Example → Digital Signature → RSA_Signature.ct2.
3. Modify Message (Optional)
Double-click the plaintext input block to edit the message.
4. Run the Workflow
Press F5 to execute. It will show:
• The hashed message
• Signed message (encrypted with private key)
• Signature verification result (with public key)
5. Tamper and Re-run
Modify the original message and run again. The verification will fail, proving message
integrity.
Observation Table :-
Result :-
• The signature is valid only if:
• The original message is unchanged
• The correct public key is used for verification
• Any modification to the message causes the verification to fail, proving integrity
Conclusion :-
We have successfully demonstrated the working of digital signatures using CrypTool. The
experiment showed how a private key is used to sign a message and how the public key verifies its
authenticity and integrity.
Enrollment No:- 2203051050528 40