I'm writing a program that encodes a file using xor and print the encrypted text into another file. It technically works, however the output contains several symbols rather than only lowercase characters. How would I tell the program to only print lowercase letters, and be able to decode it back?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *args[]){
FILE *inFile, *outFile, *keyFile;
int key_count = 0;
int encrypt_byte;
char key[1000];
inFile = fopen("input.txt", "r");
outFile = fopen("output.txt", "w");
keyFile = fopen("key.txt", "r");
while((encrypt_byte = fgetc(inFile)) !=EOF)
{
fputc(encrypt_byte ^ key[key_count], outFile); //XORs
key_count++;
if(key_count == strlen(key)) //Reset the counter
key_count = 0;
}
printf("Complete!");
fclose(inFile);
fclose(outFile);
fclose(keyFile);
return(0);
}
Here is the output I get:
ÕââÐåæœ¶è”ó
I just want it to only use lowercase letters