title: xor each byte with 0x71
body: <p>I needed to read a byte from the file, xor it with 0x71 and write it back to another file. However, when i use the following, it just reads the byte as a string, so xoring creates problems.</p>
  
  <pre><code>f = open('a.out', 'r')
  f.read(1)
  </code></pre>
  
  <p>So I ended up doing the same in C.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  int main() {
    char buffer[1] = {0};
    FILE *fp = fopen("blah", "rb");
    FILE *gp = fopen("a.out", "wb");
    if(fp==NULL) printf("ERROR OPENING FILE\n");
    int rc;
    while((rc = fgetc(fp))!=EOF) {
      printf("%x", rc ^ 0x71);
      fputc(rc ^ 0x71, gp);
    }
    return 0;
  }
  </code></pre>
  
  <p>Could someone tell me how I could convert the string I get on using <code>f.read()</code> over to a hex value so that I could xor it with 0x71 and subsequently write it over to a file?</p>