Skip to content

Instantly share code, notes, and snippets.

@Cloudef
Created June 8, 2013 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cloudef/5735519 to your computer and use it in GitHub Desktop.
Save Cloudef/5735519 to your computer and use it in GitHub Desktop.
Spacerocks score decryptor/encryptor
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv)
{
FILE *f; char buf, buf2[255], read = 0, isScore = 0, *s;
if (argc < 1) return EXIT_FAILURE;
if (!(f = fopen(argv[1], "rb"))) return EXIT_FAILURE;
while (fread(&buf, 1, 1, f) == 1) {
if (!isScore && buf+128 != '\n' && read<sizeof(buf2)-1) buf2[read++] = buf+128, buf2[read] = 0;
if (argc > 2 && isScore && !strcmp(buf2, argv[2])) {
for (s = argv[3]; *s; ++s) printf("%c", *s+128); puts("\n");
while (fread(&buf, 1, 1, f) == 1 && buf+128 != '\n');
} else {
printf("%c", (argc>2?buf:buf+128));
}
if (buf+128 == '\n') isScore = !isScore, read = 0;
}
printf("\n"); fclose(f);
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment