0% found this document useful (0 votes)
6 views3 pages

Cryptography PR Teacher Manual-3

The document is a teacher manual for the Emerging Technology Lab - II (Cryptography) course at Sipna College of Engineering and Technology for the 2022-23 session. It includes a practical exercise on implementing a Modified Caesar Cipher in C++, detailing both encryption and decryption processes. Sample outputs for both encryption and decryption are provided for clarity.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Cryptography PR Teacher Manual-3

The document is a teacher manual for the Emerging Technology Lab - II (Cryptography) course at Sipna College of Engineering and Technology for the 2022-23 session. It includes a practical exercise on implementing a Modified Caesar Cipher in C++, detailing both encryption and decryption processes. Sample outputs for both encryption and decryption are provided for clarity.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Sipna College of Engineering and Technology, Amravati

Department of Computer Science and Engineering


Session 2022-23
Teacher Manual
Branch: Computer Science and Engineering Class: III Year
Subject: Emerging Technology Lab -II(Cryptography) Semester: VI

Practical No 1. Compile Modified Caesar Cipher


Program:

#include<iostream>
#include<string.h>
using namespace std;
int main() {
cout<<"Enter the message:\n";
char msg[100];
cin.getline(msg,100); //take the message as input
int i, j, length,choice,key;
cout << "Enter key: ";
cin >> key; //take the key as input
length = strlen(msg);
cout<<"Enter your choice \n1. Encryption \n2. Decryption \n";
cin>>choice;
if (choice==1) //for encryption{
char ch;
for(int i = 0; msg[i] != '\0'; ++i) {
ch = msg[i];
//encrypt for lowercase letter
If (ch >= 'a' && ch <= 'z'){
ch = ch + key;
if (ch > 'z') {
ch = ch - 'z' + 'a' - 1;
}
msg[i] = ch;
}
//encrypt for uppercase letter
else if (ch >= 'A' && ch <= 'Z'){
ch = ch + key;
if (ch > 'Z'){
ch = ch - 'Z' + 'A' - 1;
}
msg[i] = ch;
}
}
printf("Encrypted message: %s", msg);
}
else if (choice == 2) { //for decryption
char ch;
for(int i = 0; msg[i] != '\0'; ++i) {
ch = msg[i];
//decrypt for lowercase letter
if(ch >= 'a' && ch <= 'z') {
ch = ch - key;
if(ch < 'a'){
ch = ch + 'z' - 'a' + 1;
}
msg[i] = ch;
}
//decrypt for uppercase letter
else if(ch >= 'A' && ch <= 'Z') {
ch = ch - key;
if(ch < 'A') {
ch = ch + 'Z' - 'A' + 1;
}
msg[i] = ch;
}
}
cout << "Decrypted message: " << msg;
}
}
Output:
For encryption:
Enter the message:
tutorial
Enter key: 3
Enter your choice
1. Encryption
2. Decryption
1
Encrypted message: wxwruldo

For decryption:
Enter the message:
wxwruldo
Enter key: 3
Enter your choice
1. Encryption
2. Decryption
2
Decrypted message: tutorial

You might also like