Sunday, May 20, 2018

Hash Function Encryption - Decryption Program

/* 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:



No comments:

Post a Comment

Project on Library Management System (C++)

=> The project titled Library Management system is Library management software for monitoring and controlling the transactions in a lib...