/* Program to implement Hash Function encryption and decryption technique.
*/
#include<string.h>
#include<iostream>
using namespace std;
int main()
{
string m,k;
cout<<"\nEnter the Message to Encrypt: ";
getline(cin,m);
cout<<"Enter Key: ";
getline(cin,k);
char enc[m.size()];
for(int i=0;i<m.size();i++)
{
enc[i]=m[i]^k[i%k.size()];
cout<<m[i]<<" XOR "<<k[i%k.size()]<<" ";
cout<<enc[i]<<endl;
}
cout<<"\nEncrypted message: ";
for(int i=0;i<m.size();i++)
{
cout<<enc[i]<<" ";
}
cout<<"\nDecrypted message: ";
string dec;
for(int i=0;i<m.size();i++)
{
dec[i]=enc[i]^k[i%k.size()];
cout<<dec[i];
}
cout<<endl<<endl;
return 0;
}
OUTPUT SCREEN:
*/
#include<string.h>
#include<iostream>
using namespace std;
int main()
{
string m,k;
cout<<"\nEnter the Message to Encrypt: ";
getline(cin,m);
cout<<"Enter Key: ";
getline(cin,k);
char enc[m.size()];
for(int i=0;i<m.size();i++)
{
enc[i]=m[i]^k[i%k.size()];
cout<<m[i]<<" XOR "<<k[i%k.size()]<<" ";
cout<<enc[i]<<endl;
}
cout<<"\nEncrypted message: ";
for(int i=0;i<m.size();i++)
{
cout<<enc[i]<<" ";
}
cout<<"\nDecrypted message: ";
string dec;
for(int i=0;i<m.size();i++)
{
dec[i]=enc[i]^k[i%k.size()];
cout<<dec[i];
}
cout<<endl<<endl;
return 0;
}
OUTPUT SCREEN:
No comments:
Post a Comment