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

   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++)
	cout << "Unable to open file";

Using this idiom is naughty, naughty!

>ofstream myfile3 ("Ciphertext.txt");
Reading and writing SHOULD be done in binary mode when encryption is involved.

>while(!myfile1.eof()) // for the image encryption what can we use to encrypt instead of this idiom
>ofstream myfile3 ("Ciphertext.txt", ios::out | ios::app | ios::binary);

Yes the file to copy the encrypted data is the ciphertext.txt file..
So how can the image to be encrypted be taken as 16 bytes each for encryption till end of the image and reconstructed back to get the original image...
Please help me out how we can encrypt the image..

You keep asking the same question in multiple forum posts. You asked this question last week in this post: http://www.daniweb.com/forums/thread107197.html

Now you are starting a new post with the same problem. Essentially you have broken down your problem (encrypting an image given a text hash) and you keep posting new threads asking for code for each piece.

Hi timefractal, in fact i need to encrypt files with different file sizes.. which has been solved in this forum..
Now my program must be able to encrypt an image also..
I don't have an idea on the image encryption codings just got some hints in the other threads that take the bytes in 16 blocks the program don't care about the type of file encryption ... so was just asking for some links in the other threads...
Now that the first problem was solved that is why i started this new thread...
Anyways can anyone help me on how to proceed now for the image encryption

I don't know if this is a dead thread or not but have you noticed you have a variable BC that isn't defined anywere

hai i want to encrypt the image using aes algorithm

PixelCryptor – Securely encrypt files with image key

It spreads a lot of methods for hiding document into image on the Internet, just in order to achieve the goal of encryption, unfortunately, not only the process is very troublesome, but also it is impossible to realize the encryption of multiple files or folders.