hello all. i'm having a problem while encrypting some data in the file. i'm using simple xor for that. lets say i have this struct:
struct MyFile{
char fileName[128];
int account;
float balance;};
saving this as a binary file is working properly but when i use xor to encrypt the filename in the struct and save the struct to hd then reading the struct and decrypting the filename is not showing the characters correctly. i'm using this simple function for the encryption/decryption purpose.
static void Codec(const char *key,int keySize,char* in,char *result,int length)
{
for(int i=0;i<length;i++)
result[i]=in[i]^key[i%keySize];
}
Note that when i encrypt the filename and directly decrypt it in memory the result is right. what am i missing like why is it being changed when saved on the hard disk. please reply asap and tnx in advance...