Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
A deterministic and reversible random number generator.
Ideal for generative art, as well as games for varied entity behavior.
npm install arbitrary
import arbitrary from 'arbitrary';
// Creates a Generator with a random seed.
let generate = new arbitrary.Generator();
console.log( generate.next.number(-10, 10) );
console.log( generate.next.percent() );
console.log( generate.next.bits(1) );
console.log( generate.next.bits(32) );
import arbitrary from 'arbitrary';
// Create a Generator with a seed
let deterministic = new arbitrary.Generator(42);
// Will always be: 0.2523451747838408
console.log( deterministic.next.percent() );
// Will always be: 22
console.log( deterministic.next.bits(8) );
// Will always be: 5772.811982315034
console.log( deterministic.next.number(0, 10000) );
import arbitrary from 'arbitrary';
// Create a Generator with a seed
let generate = new arbitrary.Generator();
console.log( generate.next.number(0, 10000) );
console.log( generate.next.number(-10, 10) );
console.log( generate.next.percent() );
console.log( generate.next.bits(1) );
console.log( generate.next.bits(32) );
// Now generate the reverse stream of the above numbers
console.log( generate.prev.bits(1) );
console.log( generate.prev.percent() );
console.log( generate.prev.number(-10, 10) );
console.log( generate.prev.number(0, 10000) );
/**
Output will be:
0.734807450324297
-3.3194907444994897
0.9332054262049496
1
3735025540
1
0.9332054262049496
-3.3194907444994897
0.734807450324297
*/
The scramble function is best used for turning sequences of ordered numbers (Ex. an increasing counter)
and scrambling the bits to get random number. It also reversible via arbitrary.descramble()
.
A few obvious utilizing scrambling:
Generator .next/.prev
can be forwarded/reversed, but
it can only do so a single step at a time, making large jumps in a sequence
take proportionally more CPU per distance jumped.Generate
state and jump to another point in the sequence it generates.Important: Use Generator .next/.prev if
you don't need this focus but just want a series of random numbers as scramble
/unscramble
are computationally
more expensive.
import arbitrary from 'arbitrary';
// Scramble the bits of an unsigned 32 bit integer
const scrambled42 = arbitrary.scramble(42);
// Should print '1077848774'
console.log(scrambled42);
// Reverse the scrambling to get back the original number
const unscrambled42 = arbitrary.descramble(scrambled42);
// Should print '42'
console.log(unscrambled42)
Coming soon. See examples above.
git clone git@github.com:francoislaberge/arbitrary.git
cd arbitrary
npm run watch
npm run build
Do the usual npm version bump then publish.
npm version <major|minor|patch>
git push; git push --tags
npm publish
The tests must be built before they can be run. So use either the build or watch approach below before running the tests.
All tests are run automatically on push via our travis-ci integration
npm run test
Automatically builds tests when any source code changes (test or regular).
npm run watch-test
npm run build-test
FAQs
Efficient Reversible Number Generator
We found that arbitrary 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
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.