# Breaking a Mersenne-twister RNG with unsequential outputs

Pardon me for this newbie-ish question. I'm still a novice in cryptography . I have an application that outputs random numbers from 0 - 12 (endpoints inclusive) unsequentially (some outputs are thrown off) using the mersenne twister algorithm and i would like to break and predict its seed in Python but i don't know what to program?

Once again please pardon my little knowledge in this space.

• Are you taking the twister outputs modulo 13? – Adrian Self Jun 16 '20 at 3:51
• Or if you don't know implementation, what method call are you making in python? – Adrian Self Jun 17 '20 at 15:14
• i use random.randint(0, 12) – Ozichukwu Jun 21 '20 at 11:49

• "With a 32 or 64 bit word length, a set of numbers in that range will not reveal nearly enough information about the state"; that depends on the mapping between the 32 bit outputs and the value [0,12]. If the mapping is $\lfloor n / (2^{32}/13) \rfloor$, that gives you the msbit sometimes, which is quite enough. If it's $n \bmod 13$, well, there's no immediate way to attack that – poncho Nov 14 '20 at 17:10