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

EXPERIMENT 2. Encryption Decryption

The document outlines an experiment on writing a program for encryption and decryption, explaining the concepts of transforming data into an unintelligible form and back. It includes a simple example of encryption using a letter-shifting algorithm and provides a C program that implements both encryption and decryption functionalities. The conclusion states that the author has understood the concepts and their implementation through the provided code.

Uploaded by

Reuben Anthony
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)
4 views3 pages

EXPERIMENT 2. Encryption Decryption

The document outlines an experiment on writing a program for encryption and decryption, explaining the concepts of transforming data into an unintelligible form and back. It includes a simple example of encryption using a letter-shifting algorithm and provides a C program that implements both encryption and decryption functionalities. The conclusion states that the author has understood the concepts and their implementation through the provided code.

Uploaded by

Reuben Anthony
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

AISSMS COE, PUNE TE (E&TC)

Experiment No:02

Title: Write a program for Encryption and Decryption.

Aim: Write a program for Encryption and Decryption.

Theory:

Network Data Encryption :


Encryption is the process of transforming data into an unintelligible form to prevent
the unauthorized use of the data. To read an encrypted file, you must have access to
a secret decryption key or password. Unencrypted data is called plain text;
encrypted data is called cipher text. A cipher is an encryption-decryption algorithm.

Network Data Decryption :


Decryption is the process of transforming data that has been rendered unreadable
through encryption back to its unencrypted form. In decryption, the system extracts
and converts the garbled data and transforms it to texts and images that are easily
understandable not only by the reader but also by the system. Decryption may be
accomplished manually or automatically. It may also be performed with a set of keys
or passwords.

Example
An employer wants to send some sensitive documents to an employee for processing
but can’t risk hackers getting hold of the documents and reading them. The
employer can encrypt the documents and then send them to the employee who can
then decrypt the documents using an employer-provided encryption key. They can
then start working on the documents as they would normally.
More specifically, let’s say a document contains a top-secret word like “ALUMINUM.”
This word could be encrypted with an algorithm that replaces each letter with the
letter that follows it in the alphabet.
So, the “A” in ALUMINUM would become “B,” the “L” would become “M” and so on to
give a cipher “BMVNJOVN.” Anyone who wants to know what the original message
was must know the algorithm which was used to encrypt the original information.
This is a very simple example so one can easily tell what the original message was.
In the real world, far more complicated algorithms are used to encrypt information.
In any case, the sending party would let the receiving party know the encryption key.
In this case, the key is to replace each letter with the letter that follows it in the
alphabet. Using this key, the receiving party would decrypt the message, read the
contents and move on.

Write a Program for Encryption & Decryption


#include <stdio.h>

Network Security (Elective II)


AISSMS COE, PUNE TE (E&TC)

int main()
{
int i, x;
char str[100];
printf("\nPlease enter a string : ");
gets(str);
printf("\nPlease Enter your choice : \n");
printf("1. Encryption\n");
printf("2. Decryption\n");
scanf("%d", &x);
//using switch case statements
switch(x)
{
case 1:
for(i = 0; (i < 100 && str[i] != '\0'); i++)
str[i] = str[i] + 3; //the key for encryption is 3 that is added to ASCII value
printf("\nEncrypted string is : %s\n", str);
break;
case 2:
for(i = 0; (i < 100 && str[i] != '\0'); i++)
str[i] = str[i] - 3; //the key for encryption is 3 that is subtracted to ASCII value
printf("\nDecrypted string is : %s\n", str);
break;
default:
printf("\nError : Please Enter correct choice \n");
}
return 0;
}

OUTPUT :

Network Security (Elective II)


AISSMS COE, PUNE TE (E&TC)

Conclusion:

Therefore, I have understood and studied the concept of encryption and decryption
and also analysed its functioning using a C++ Code.

Network Security (Elective II)

You might also like