Skip to content

Instantly share code, notes, and snippets.

@kasramp
Last active August 3, 2020 19:47
Show Gist options
  • Save kasramp/e1818d6f48db6d9c4addc29867d1b9c7 to your computer and use it in GitHub Desktop.
Save kasramp/e1818d6f48db6d9c4addc29867d1b9c7 to your computer and use it in GitHub Desktop.
This is simple XOR cipher code implementation to do simple encoding and decoding via using XOR concept
#include <stdio.h>
int main(int args, char *argv[])
{
char ch;
char key = argv[3][0];
FILE *fp;
FILE *fp1;
fp = fopen(argv[1], "r");
fp1 = fopen(argv[2], "w+");
if (fp == NULL)
{
printf("Cannot open the file \n");
return -1;
}
while (!feof(fp))
{
fscanf(fp, "%c", &ch);
fprintf(fp1, "%c", ch ^ key);
}
fclose(fp);
fclose(fp1);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment