Skip to content

Instantly share code, notes, and snippets.

@vanhoefm
Created March 23, 2015 00:33
Show Gist options
  • Save vanhoefm/3d695e0269c89c7a7a1f to your computer and use it in GitHub Desktop.
Save vanhoefm/3d695e0269c89c7a7a1f to your computer and use it in GitHub Desktop.
Find PRNG seed
#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