Gathering detailed insights and metrics for jittertrng
Gathering detailed insights and metrics for jittertrng
npm install jittertrng
Typescript
Module System
Min. Node Version
Node Version
NPM Version
72
Supply Chain
94.4
Quality
75.7
Maintenance
100
Vulnerability
80.9
License
JavaScript (68.32%)
C++ (27.62%)
Python (4.06%)
Total Downloads
2,966
Last Day
5
Last Week
16
Last Month
45
Last Year
197
3 Stars
47 Commits
3 Watching
7 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
0.1.0
Package Id
jittertrng@0.1.0
Unpacked Size
117.05 kB
Size
34.55 kB
File Count
31
NPM Version
6.12.1
Node Version
12.13.1
Cumulative downloads
Total Downloads
Last day
400%
5
Compared to previous day
Last week
33.3%
16
Compared to previous week
Last month
462.5%
45
Compared to previous month
Last year
-24.8%
197
Compared to previous year
2
1
This is a wrapper of jitterentropy-library, which is a hardware RNG based on CPU timing jitter, wrapped for Node.js.
For more information about this library, it is better to visit its site, www.chronox.de/jent.html.
This is my first attempt to create a native C++ module for Node.js, therefore it might be many bugs and might be just works on my machine. I have made some modification on the original source (Added a header) in order to make it compilable on Windows platform.
Please refer to documentation for exposed classes. :)
Example
1const { JitterTrng } = require('jittertrng'); 2 3const rng = new JitterTrng(); 4 5async function() { 6 console.log(await rng.randomAsync(100)); // Asynchronous call, get a float-point number between 0 and 100 7} 8 9console.log(rng.randomInt(1234, 5678)); // Synchronous call, gets an integer number between 1234 and 5678 10 11const randombytes = rng.generate(100); // Gets 100 random bytes as a buffer. 12 13rng.generateAsync(10000, (err, buffer) => { 14 // Gets 10000 random bytes as a buffer. 15}); 16// Getting large amount of random bits at once is slow, therefore asynchronous call will be safer as this does not block the javascript execution thread. 17// Also, all asynchronous methods also provides old-school callback flow for use.
Or in a more convenient way:
1const { RandomStream } = require('jittertrng'); 2 3(async() => { 4 const rng = await RandomStream.create(1024); // Create a buffered random pool with 1024 bytes. 5 // You also can use `new RandomStream(...)` constructor, but you have to be patient 6 // because the pool does not immediately get ready after it constructs. (Async logic is used here) 7 rng.random(); 8 rng.random(1, 10); 9 rng.randomInt(1, 100); 10 // Keep in mind that if the pool is already drain (and of cause it will starts to fill up at the background), 11 // whatever you want to get, you will get undefined. 12})();
As this is a true random number generator, it is not very efficient to get large amount of random numbers directly, even here I have made asynchronous direct and buffered methods to access the entropy. If you needs random values immediately at anytime and doesn't really mind the randomness, it is recommend to use other pseudo random number generators as a fallback, or you have another option to just use this as a source of seed for other pseudo random number generators.
Also, I don't make the memory secure here, this wrapper just pulls the random bytes out and pass it to the JavaScript engine, nothing is protecting them to prevent third party to access or spy on them. So if anyone wants to use this in something secure-critical is not recommend.
You can use
1$ npm i jittertrng
to install this package.
As this is a native addon module, to use it you will have to prepare suitable C++ compilers (gcc for *nix systems and Visual C++ with Windows SDK for Windows systems) and node-gyp as a global dependency. Prebuilt binaries are not yet available, sorry about that :(
Yes! If you don't mind my messy code and you want to make it better, issues and pull-requests are welcome!
Original jitterentropy-library is dual-licensed with BSD and GPLv2, all original notes are kept untouched in its own dependency directory. The wrapper and binding codes are licensed with MIT.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/24 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
13 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More