saghul / sjs

Skookum JS: a JavaScript runtime
http://sjs.saghul.net
MIT License
98 stars 13 forks source link

modules: add random module #23

Closed saghul closed 8 years ago

saghul commented 8 years ago

A non-cryptographically safe random helper thingy.

TBD: base it on Math.random (Duktape's implementation here) or something else (Mersene Twister I guess?).

References: https://docs.python.org/3.6/library/random.html http://ruby-doc.org/stdlib-2.1.2/libdoc/securerandom/rdoc/SecureRandom.html https://developer.mozilla.org/en-US/docs/Web/API/RandomSource/getRandomValues https://github.com/ckknight/random-js http://ruby-doc.org/core-2.2.0/Random.html https://github.com/MersenneTwister-Lab/TinyMT https://github.com/dajobe/libmtwist https://github.com/cslarsen/mersenne-twister https://github.com/ruby/ruby/blob/trunk/random.c

saghul commented 8 years ago

Also os.urandom, using the system CSPRNG.

saghul commented 8 years ago

os.urandom: https://github.com/saghul/sjs/commit/2bb7372173f1760725e445e19179197847b40c5e