B. K. BIRLA COLLEGE OF ARTS, SCIENCE AND COMMERCE (AUTONOMOUS) KALYAN DEPARTMENT OF INFORMATION TECHNOLOGY CERTIFICATE This is to certify that Mr /Ms Exam Seat No. has satisfactorily completed the practical in for the fulfillment of Bachelors of Information Technology (Semester - VI) of the University of Mumbai for the year 2022 - 2023. Place: Date: Signature of Examiner Professor In - Charge Head Dept. of Information Technology - : INDEX : - SrNo Practical Name Sign 1 Write a program to implement Basic Ceasar Cipher 2 Write a program to implement Modified Ceasar Cipher 3 Write a program to implement Monoalphabetic Cipher 4 Write a program to implement Homophonic Cipher PRACTICAL - 1 Q1] Write A Program for Simple Caesar Cipher Code: #include<stdio.h> #include<ctype.h> void main() { char text[500], ch; int key=3 , i, k; printf("Enter a message to encrypt: "); scanf("%s", text); for(i=0;text[i];i++) { if (text[i]>='a' && text[i]<='z') { if(text[i]+key > 'z') text[i] = text[i]+key - 26; else text[i] = text[i]+key; } if (text[i]>='A' && text[i]<='Z') { if(text[i]+key > 'Z') text[i] = text[i]+key - 26; els text[i] = text[i]+key; } if (text[i]>='0' && text[i]<='9') { if(text[i]+key > '9') text[i] = text[i]+key - 10; else text[i] = text[i]+key; } } printf("the encrypt text is %s" , text); return 0; } Output: PRACTICAL - 2 Q2] Write A Program for Modified Caesar Cipher Code: #include<stdio.h> #include<ctype.h> void main() { char text[500], ch; int key=3 , i, k; printf("Enter a message to encrypt: "); scanf("%s", text); printf("Enter a key: (except 3) "); scanf("%d",&key) ; for(i=0;text[i];i++) { if (text[i]>='a' && text[i]<=' z') { if(text[i]+key > 'z') text[i] = text[i]+key - 26; else text[i] = text[i]+key; } if (text[i]>='A' && text[i]<='Z') { if(text[i]+key > 'Z') text[i] = text[i]+key - 26; else text[i] = text[i]+key; } if (text[i]>='0' && text[i]<='9') { if(text[i]+key > '9') text[i] = text[i]+key - 10; else text[i] = text[i]+key; } } printf("the encrypt text is %s" , text); return 0; } Output: PRACTICAL - 3 Q3] Write a program to implement Monoalphabetic Cipher Code: Code: #include <stdio.h> #include <string.h> // Function to encrypt a message using Monoalphabetic Cipher void monoalphabeticEncrypt(char message[], char key[]) { int i, j; int len = strlen(message); char encryptedMessage[len]; for (i = 0; i < len; i++) { // Find the correspo nding character in the key for each character in the message if (message[i] >= 'a' && message[i] <= 'z') { encryptedMessage[i] = key[message[i] - 'a']; } else if (message[i] >= 'A' && message[i] <= 'Z') { encryptedMe ssage[i] = key[message[i] - 'A']; } else { encryptedMessage[i] = message[i]; } } encryptedMessage[len] = ' \ 0'; printf("Encrypted Message: %s \ n", encryptedMessage); } int main() { char message[100]; char key[26] = "QWERTYUIOPASDFGHJKLZXCVBNM"; printf("Enter a message to encrypt: "); gets(message); monoalphabeticEncrypt(message, key); return 0; } Output: PRACTICAL - 4 Q3] Write a program to implement Homophonic Cipher Code: Code: #include <stdlib.h> #include <time.h> #include <string.h> #define ALPHABET_SIZE 26 #define MAX_CHARS_PER_SYMBOL 3 int main() { char plainText[1000], cipherText[3000], key[ALPHABET_SIZE][MAX_CHARS_PER_SYMBOL + 1]; int i, j, k, len, choice; srand(time(NULL)); printf("Enter the plaintext: "); scanf("%[^ \ n]s", plainText); len = strlen(plainText); for (i = 0; i < ALPHABET_SIZE; i++) { int numChars = rand() % MAX_CHARS_PER_SYMBOL + 1; for (j = 0; j < numChars; j++) { key[i][j] = 'a' + rand() % ALPHABET_SIZE; } key[i][numChars] = ' \ 0'; } printf("Key: \ n"); for (i = 0; i < ALPHABET_SIZE; i++) { printf("%c: %s \ n", 'a' + i, key[i]); } printf("Enter 1 to encrypt or 2 to decrypt: "); scanf("%d", &choice); if (choice == 1) { for (i = 0; i < len; i++) { if (plainText[i] == ' ') cipherText[i] = ' '; else { k = plainText[i] - 'a'; int numChars = strlen(key[k]); i nt charIndex = rand() % numChars; cipherText[3 * i] = key[k][charIndex]; cipherText[3 * i + 1] = charIndex + '1'; cipherText[3 * i + 2] = ' '; } } cipherText[3 * len] = ' \ 0'; printf("Encrypted text: %s", cipherText); } else if (choice == 2) { for (i = 0; i < len; i += 3) { if (plainText[i] == ' ') continue; k = plainText[i] - 'a'; int charIndex = plainText[i+1] ; cipherText[i/3] = key[k][charIndex]; } cipherText[len/3] = ' \ 0'; printf("Decrypted text: %s", cipherText); } else { printf("Invalid choice!"); } return 0; } Output: