Hello,
I need to encrypt an image but my program is accepting 16 bytes of data for encryption from a file named plaintext.txt..
The program is encrypting data in blocks of 16 bytes that is the 1st 16 bytes are read then it is encrypted and saved in the ciphertext.txt file till eof plaintext.txt
Now i want to encrypt an image how can we encrypt the image.. please help me out..
One way of encrypting the image is by replacing the file plaintext.txt by the image name but its not working..
I am fwding the codes please help me out..
char d;
ifstream myfile1 ("Plaintext.txt");
ofstream myfile3 ("Ciphertext.txt");
myfile1.get(d); //priming read
while(!myfile1.eof())
{
for ( j=0; j<BC; j++) // BC=4
for ( i=0; i < 4; i++)
{
a[i][j] = d; // plaintext
//cout<<a[i][j]; // to chk how many plaintext is copied
myfile1.get(d); //reads first element of next block
}
Encrypt(a, rk); // function call to encrypt data
if (myfile3.is_open())
{
for(j=0; j< BC; j ++)
for ( i=0; i<4; i++)
myfile3<<a[i][j];
}
else
cout << "Unable to open file";
}
myfile3.close();
myfile1.close();