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.
promised-entropy
Advanced tools
Generate more entropy to combine with Node's crypto.rng or window.crypto
A promisified adaptation of more-entropy
Better entropy, I promise
The easiest way to generate good pseudorandom numbers in the browser is with window.crypto.getRandomValues
, and in Node.js you can use crypto.rng
.
But for the truly paranoid, getting even more entropy is a good idea. For example, one might seed their own key generator with a combination
of window.crypto
and a series of coordinates collected from mouse movements or key mashes.
Even though the mouse movements of the user are not very random, it's extra noise, adding a layer of safety. Perhaps each [x,y] mouse location is worth a bit or two of entropy.
more-entropy
achieves similar results but without user interaction or ugly integration with your DOM.
It generates large numbers by counting how many operations it can perform in a unit of time, which fluctuates
unpredictably based on other system processes and low-level architectural specifics (like cache misses and FPU pipelines).
A good use of this module is to combine its output with
window.crypto.getRandomValue
or crypto.rng
, and use the
result as a seed for a deterministic random bit generator (like
HMAC_DRBG).
You'll have an extra layer of protection if you're afraid that the
standard random number generators are compromised.
npm install --save promised-entropy
const m = require('promised-entropy')
// create a generator, which can provide you with some entropy
entropy = await m.promisedEntropy(bits)
// get an array of integers with at least 256 bits of combined entropy:
let entropy = await m.promisedEntropy(256)
console.dir(entropy) // [-4358,543,9089,...]
Promised entropy can also be called with custom options
const m = require('promised-entropy')
const params = {
'loop_delay': 10 // how many milliseconds to pause between each operation loop. A lower value will generate entropy faster, but will also be harder on the CPU
'work_min': 1 // milliseconds per loop; a higher value blocks the CPU more, so 1 is recommended
'auto_stop_bits': 4096 // the generator prepares entropy for you before you request it; if it reaches this much unclaimed entropy it will stop working
'max_bits_per_delta': 4 // a safety cap on how much entropy it can claim per value; 4 (default) is very conservative. a larger value will allow faster entropy generation
};
// create a generator, which can provide you with some entropy
entropy = await m.promisedEntropy(bits, params)
// get an array of integers with at least 256 bits of combined entropy:
let entropy = await m.promisedEntropy(256, params)
console.dir(entropy) // [-4358,543,9089,...]
This generator repeatedly does as many floating point operations as it can in 1ms-2ms time periods (typically many thousands), and compares this value to previous attempts. The delta is then added to a collection with a very conservative estimate for bits of entropy.
Much like the mouse movement technique, we are collecting a lot of data and assuming it's just a little bit random.
generate
can be called as many times as you like, even concurrently; it will call back with uniquely calculated data to each requestFAQs
Generate more entropy to combine with Node's crypto.rng or window.crypto
The npm package promised-entropy receives a total of 3 weekly downloads. As such, promised-entropy popularity was classified as not popular.
We found that promised-entropy 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.