Professional Documents
Culture Documents
Cryptographylab 1
Cryptographylab 1
Name: C. Rohith
Register No: 21BCE0810
Slot: L13 + L 14
Name: C. Rohith Register: 21BCE0810
Output: Plaintext string obtained by decrypting the ciphertext using the Hill Cipher
with the provided key.
Procedure:
Compute the inverse of the key matrix modulo m using the inverseMatrix function.
Divide the ciphertext into blocks of two characters.
For each block:
Convert the characters to their corresponding numerical values.
Perform matrix multiplication with the inverse key.
Take the modulo m of each result.
Convert the resulting numerical values back to characters and append them to the
plaintext.
4. main Function:
Input: None.
Output: None (prints the ciphertext and decrypted text).
Procedure:
Initialize a plaintext string and a 2x2 key matrix.
Encrypt the plaintext using the hillCipherEncrypt function and print the ciphertext.
Decrypt the ciphertext using the hillCipherDecrypt function and print the
decrypted text.
5. Output:
Print the ciphertext and decrypted text obtained from the encryption and decryption
processes.
Name: C. Rohith Register: 21BCE0810
Code:
#include <iostream>
#include <vector>
int main() {
cout << "Name: C. Rohith" << endl;
cout << "Register No: 21BCE0810" << endl;
string plaintext = "hello";
vector<vector<int>> key = { {1, 2}, {3, 4} };
int m = 26;
string ciphertext = hillCipherEncrypt(plaintext, key, m);
cout << "Ciphertext: " << ciphertext << endl;
string decryptedText = hillCipherDecrypt(ciphertext, key,m);
cout << "Decrypted Text: " << decryptedText << endl;
return 0;
}
Output:
Name: C. Rohith Register: 21BCE0810
2. Find the ciphertext from plaintext and reconstruct the plain text from ciphertext
for the following using Playfair cipher manually
• Plain text: COME TO CNS LAB
• Key : THANK YOU
A.
Name: C. Rohith Register: 21BCE0810
3. Find the ciphertext from plaintext and reconstruct the plain text from ciphertext
for the following using Vigenere cipher manually
• Plain text: VELLORE INSTITUTE OF TECHNOLOGY
• Key : SCOPE
A.
Name: C. Rohith Register: 21BCE0810
4. Find the ciphertext from plaintext and reconstruct the plain text from ciphertext
for the following using Hill cipher manually
• Plain text: WELCOME TO VIT
• Key : NICE
Name: C. Rohith Register: 21BCE0810
Name: C. Rohith Register: 21BCE0810
5. Find the ciphertext from plaintext and reconstruct the plain text from ciphertext
for the following using Hill cipher manually
• Plain text: COMPUTER SCIENCE AND ENGINEERING
• Key : ANALYTICS
A.
Name: C. Rohith Register: 21BCE0810
Name: C. Rohith Register: 21BCE0810
Name: C. Rohith Register: 21BCE0810
Name: C. Rohith Register: 21BCE0810
Name: C. Rohith Register: 21BCE0810