Last active
August 3, 2020 19:47
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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