Encryption & Decryption Explained.
Today I am going to discuss about the most happening topic of Internet i.e. Encryption and Decryption.
What is Encryption?
A data converted into unreadable format is called encrypted data and the process is called is ENCRYPTION.
What is Decryption?
Converting an encrypted data to unencrypted format i.e. readable format is called DECRYPTION.
How does it work?
Every encryption has it own algorithm. Unless and until we know the algorithm we can’t decrypt it and thus we can call it KEY.
I will show you a simple encryption program to explain the process.
As we know every character set has its own ASCII value which is a numeric number.
Let see a example.
| Character | ASCII |
| A | 65 |
| a | 97 |
| B | 66 |
| b | 98 |
| C | 97 |
| c | 99 |
and goes on………………………
Now let us take a string -----“ IT IS FUN TO LEARN COMPUTER ” , I am going to encrypt it with a simple C program. The algorithm I am using in this is, I find out the ASCII codes of the string which are numerical values, after that I add a random number with every ASCII value. By doing this the ASCII code will change thus the characters also.
To decrypt it we must know the number I added with the original ASCII code. So here we can call it KEY i.e. the number. So to get the original code we need to subtract the same number from the encrypted ASCII code. Now we will get the original ASCII code thus the original character set.
THE PROGRAM:-
#include .<<stdio.h>>.
#include .<<conio.h>>.
main ()
{
char a[100], b[100], c[100] ; //* Declaring the Variables
int i, x;
clrscr();
for(i=0;i<=100;i++) //* Setting the value of variables to zero
{
a[i] = b[i] = c[i] = 0; /*
}
printf("Enter a String:-"); //* Getting the String.
gets(a);
printf("\n");
printf("Enter a Number:- "); //* Getting the Key
scanf("%d", &x);
for(i=0; a[i]!='\0'; i++)
{
b[i] = a[i] + x; //* Adding the number to ASCII (ENCRYPTION)
c[i] = b[i] - x; //* Subtracting the number from ASCII (DECRYPTION)
}
clrscr();
printf("\n");
puts("Encrypted form of your string is :- ");
printf("\n");
puts(b); //* Showing the Encrypted Data
printf("\n");
puts("Decrypted form of your string is :-");
printf("\n"); //* Showing the Decrypted Data
puts(c);
getch();
}
And here is the OUTPUT :-

