我正在尝试在 c 中进行某种异或文件加密,并在 javascript 中进行解密(以此为基础,现在我遇到了以下问题:
比如说我想73^122在 C 中做,结果是57,但在 javascript 中相同的操作会产生51。为什么会发生这种情况,以及解决它的正确方法是什么?
这是加密功能的一些C代码
void encrypt_data(FILE* input_file, FILE* output_file, char* key)
{
  int key_count = 0; //Used to restart key if strlen(key) < strlen(encrypt)
  int encrypt_byte;
  while( (encrypt_byte = fgetc(input_file)) != EOF) //Loop through each byte of file until EOF
  {
    //XOR the data and write it to a file
    fputc(encrypt_byte ^ key[key_count], output_file);
    printf("original %d\n", encrypt_byte); //yields 73
    printf("xoring with %d\n", key[key_count]); // yields 122
    printf("xored %d\n", encrypt_byte ^ key[key_count]); // yields 57
    break; //breaking just for example purpose
    //Increment key_count and start over if necessary
    key_count++;
    if(key_count == strlen(key))
        key_count = 0;
  }
}