Created
March 23, 2015 00:33
-
-
Save vanhoefm/3d695e0269c89c7a7a1f to your computer and use it in GitHub Desktop.
Find PRNG seed
This file contains 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 <stdint.h> | |
int is_correct(uint32_t seed) { | |
uint8_t hexkey[] = "\xA4\x3D\xF6\xF3\x74"; | |
for (uint32_t i = 0, x = seed; i < 5; ++i) { | |
x = (214013 * x + 2531011) & 0xFFFFFF; | |
if (hexkey[i] != (x >> 16)) return 0; | |
} | |
return 1; | |
} | |
int main(int argc, char *argv[]) { | |
for (uint32_t seed = 0; seed < (1 << 24); seed++) | |
if (is_correct(seed)) | |
printf("Seed: %03X\n", seed); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment