Encrypting a binary file
Posted on 2004-08-18
I was trying to secure data going through the wire so I put the data in binary format. Now thats not secure enough....you can still see the values that noody should see so I am now trying first steps of encrypting it.
I have the following code on a windows C compiler this has to be on Linux please keep this in mind:
unsigned char aByte;
FilePrev = fptr4;
noofbytesread = fread(&aByte, 1, 1, fptr4);
convertedvalue = aByte ^ 189;
noofbyteswrote = fwrite(&convertedvalue, 1, 1, FilePrev);
printf("The converted value is %d\n", convertedvalue);
This goes into infinte loop and also on Linux compiler it complains not proper args to ^ operator.
The basic idea is right and it works. It is in the file manpulation it goes into an infinite loop. It is a simple 2 byte exclusive or.
Please help me out.