Created
May 22, 2020 23:27
-
-
Save simontime/59661a189b20fc3517b20d8c9f329017 to your computer and use it in GitHub Desktop.
Encrypts & decrypts Yakuza Kiwami 2 saves (doesn't do checksum yet)
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> | |
#include <stdlib.h> | |
static const char Key[] = "STarYZgr3DL11"; | |
static const int KeyLen = 13; | |
int main(int argc, char **argv) | |
{ | |
FILE *in, *out; | |
char *data; | |
size_t sz; | |
if (argc != 3) | |
{ | |
printf("Usage: %s in.sav out.sav\n", argv[0]); | |
return 0; | |
} | |
if ((in = fopen(argv[1], "rb")) == NULL) | |
{ | |
perror("Error"); | |
return 1; | |
} | |
if ((out = fopen(argv[2], "wb")) == NULL) | |
{ | |
perror("Error"); | |
fclose(in); | |
return 1; | |
} | |
printf("Writing %s to %s...\n", argv[1], argv[2]); | |
fseek(in, 0, SEEK_END); | |
sz = ftell(in); | |
data = malloc(sz); | |
rewind(in); | |
fread(data, 1, sz, in); | |
fclose(in); | |
for (int i = 0; i < sz; i++) | |
data[i] ^= Key[i % KeyLen]; | |
fwrite(data, 1, sz, out); | |
free(data); | |
fclose(out); | |
puts("Done!"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment