Hello,
I have a binary file in which some bytes were escaped according to the following rule:
Code:
if (byte == XX || byte == YY || ...)
{
temp = byte;
byte = 0x7d;
byte+1 = tmp ^ 0x20;
}
So when I receive such a file in my program I try to decipher it by this for loop:
Code:
char escaped_file[file_len];
char original_data[file_len]
for (i=0; j=0; i < file_len; i++, j++)
{
if (escaped_file[i] == 0x7d) {
original_data[j] = escaped_file[++i] ^ 0x20;
} else {
original_data[j] = escaped_file[i];
}
Now this works perfectly for text files. However when I do the same with binary ones there is sth wrong as md5sum doesnt match. I have no idea why is that, do you? Thanks for suggestions