Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Bob Jenkins' small noncryptographic PRNG (pseudorandom number generator) ported to JavaScript.
Sometimes you want repeatable results. With this lib, you can save the seed you used, and later initialize the PRNG with the same seed and get the same sequence of pseudorandom numbers.
Also, this PRNG beats the one built into V8 on ent's chi-square test, indicating that its output is, in a sense, "more random". (The results on ent's other tests are excellent for both.)
Both BurtlePRNG and the native PRNG are incredibly fast and unlikely to be a bottleneck in your application.
You can use test.js
, which prints 10MB of random bytes to the
standard output using Node, to run your own benchmarks. On Node
0.10.28, there is no significant performance difference between
generating 32-bit unsigned integers using test.js versus equivalent
code using Math.random:
((1<<31) * 2 * Math.random()) >>> 0
If you're using Node.js, Browserify or Webpack, use the usual npm install burtleprng
and require
:
var BurtlePRNG = require('burtleprng');
Otherwise, simply include BurtlePRNG.js in a script tag. It will export a single class, BurtlePRNG.
Creates and returns a new PRNG instance. The seed argument is mandatory and should be an unsigned 32-bit integer. Reasonable ways to come up with a seed include:
Date.now() & 0x7fffffff
// or
((1<<31) * 2 * Math.random()) >>> 0
Returns a pseudorandom, unsigned 32-bit integer and advances the PRNG state.
Returns a pseudorandom floating-point number on the interval [0, 1),
similar to Math.random(), and advances the PRNG state. Equivalent to
prng.next() / 4294967296.0
.
Bob Jenkins released his original C implementation of this PRNG as public domain. Similarly, burtleprng is released under the Creative Commons CC0 Public Domain Dedication. See COPYING.txt for details.
FAQs
Fast, seeded, noncryptographic random numbers
We found that burtleprng demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.