#include <stdio.h>
#define KEY_LENGTH 7 // Can be anything from 1 to 15

main(){
  unsigned int ch;
  FILE *fpIn;
  int i;
  unsigned char key[KEY_LENGTH] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06};
  /* decryption will, in general, only work correctly when the decryption
     key matches the encryption key */

  fpIn = fopen("ctext.txt", "r");

  i=0;

  while (fscanf(fpIn, "%2x", &ch) != EOF) {
    printf("%c", ch ^ key[i % KEY_LENGTH]);
    i++;
  }
  fclose(fpIn);

  return;
}