Hacking Random Generator (linear congruential generator)
Rodion Gorkovenko

Rodion Gorkovenko @rodiongork

About: Developer, Dreamer, School-Teacher, author of CodeAbbey and few other silly projects :)

Location:
Saint-Petersburg, Russia
Joined:
Jan 16, 2020

Hacking Random Generator (linear congruential generator)

Publish Date: Feb 12 '20
12 0

New problem: Cracking "LCG" Random Generator @ CodeAbbey

Default random generators in some languages (Python, PHP7, JavaScript) switched to XorShift or Mersenne Twister. However in others - most notably, Java and linux/posix rand used in C/C++ - it still uses linear congruential generator in very simple form:

X_next = (A * X_cur + C) % M

The new problem at CodeAbbey is dedicated to exercise of hacking such generator. I.e. about predicting next results after observing few first ones.

This both helps to get better understanding of modular arithmetic - and to remember that default random generators shouldn't be used for hashing or encrypting sensitive data - or building online casinos :)

Comments 0 total

    Add comment