Skip to content

Instantly share code, notes, and snippets.

@misodengaku
Created January 17, 2014 13:21
Show Gist options
  • Save misodengaku/8473269 to your computer and use it in GitHub Desktop.
Save misodengaku/8473269 to your computer and use it in GitHub Desktop.
crypto100 decoder
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv) {
FILE* input;
FILE* output;
char k[] = "VeryLongKeyYouWillNeverGuess";
char c, p, t = 0;
int i = 0;
if (argc != 3) {
printf("USAGE: %s INPUT OUTPUT\n", argv[0]);
return 0;
}
input = fopen(argv[1], "rb");
output = fopen(argv[2], "wb");
i = 0;
p = fgetc(input) & 0xFF;
//printf("%0X", p);
c = p - k[0];
t = c;
fputc(c, output);
i++;
while ((p = fgetc(input)) != EOF) {
c = (p - (k[i % strlen(k)] ^ t) - i*i) & 0xff;;
t = c;
i++;
fputc(c, output);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment