Skip to content

Various exploit scripts for the Mersenne Twister PRNG. Includes barebones Python implementation.

License

Notifications You must be signed in to change notification settings

slightlyskepticalpotat/mersenne-twister-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mersenne-twister-tools

A collection of various programs implementing and/or related to the Mersenne Twister PRNG. This is intended to be a bare-minimum Python 3 (minimum version 3.6, as format strings are used) implementation that users can build off of. This also includes a C++ version of Boost's mt11213b Mersenne Twister, so my code for the nonstandard mt11213b variant can be verified.

Features

  • Seeding with any hashable type*

  • Saving and restoring the state

  • Pseudo-random ints and floats

  • Can be used to subclass Random

  • Derive past generated numbers

  • Original 32-bit Mersenne Twister

  • Original 64-bit Mersenne Twister

  • Boost's mt11213b Mersenne Twister

  • Custom Parameters Mersenne Twister

  • Original 32-bit Mersenne Twister Cracker

  • Original 64-bit Mersenne Twister Cracker

  • Boost's mt11213b Mersenne Twister Cracker

  • Custom Parameters Mersenne Twister Cracker

*Set the environment variable PYTHONHASHSEED = 0 to fix hashes for non-ints.

Testing

mersenne_twister.py and mersenne_cracker.py both run tests when you run them from the command line. You have to compile mt11213b.cpp and enter a number n to see the first n integers from the mt11213b generator (with the default seed 5489).

$ python3 mersenne_cracker.py
$ python3 mersenne_twister.py
$ g++ mt11213b.cpp
$ ./a.out

Contributing

Please report any bugs that you encounter, and open a pull request if you have something to add to the program. Thank you!

References

When I was creating this program, I found several resources that are useful for anyone seeking to understand the Mersenne Twister. They are listed here for reference:

About

Various exploit scripts for the Mersenne Twister PRNG. Includes barebones Python implementation.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published