Gathering detailed insights and metrics for @lukeed/csprng
Gathering detailed insights and metrics for @lukeed/csprng
Gathering detailed insights and metrics for @lukeed/csprng
Gathering detailed insights and metrics for @lukeed/csprng
A tiny (~90B) isomorphic wrapper for `crypto.randomBytes` in Node.js and browsers.
npm install @lukeed/csprng
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
68 Stars
15 Commits
2 Forks
2 Watchers
1 Branches
1 Contributors
Updated on May 02, 2025
Latest Version
1.1.0
Package Id
@lukeed/csprng@1.1.0
Unpacked Size
5.83 kB
Size
2.68 kB
File Count
12
NPM Version
8.19.2
Node Version
18.12.1
Published on
Mar 31, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
A tiny (~90B) isomorphic wrapper for
crypto.randomBytes
in Node.js and browsers.
Why?
This package allows you/dependents to import a cryptographically secure generator (CSPRNG) without worrying about (aka, checking the runtime environment for) the different crypto
implementations. Instead, by extracting a random
function into a third-party/external package, one can rely on bundlers and/or module resolution to load the correct implementation for the desired environment.
In other words, one can include the browser-specific implementation when bundling for the browser, completely ignoring the Node.js code – or vice versa.
By default, this module is set up to work with Rollup, webpack, and Node's native ESM and CommonJS path resolutions.
$ npm install --save @lukeed/csprng
General Usage
1// Rely on bundlers/environment detection 2import { random } from '@lukeed/csprng'; 3 4const array = random(12); 5// browser => Uint8Array(12) [...] 6// Node.js => <Buffer ...>
Specific Environment
1// Choose the "browser" implementation explicitly. 2//=> ! NOTE ! Will break in Node.js environments! 3import { random } from '@lukeed/csprng/browser'; 4 5const array = random(1024); 6//=> Uint8Array(1024) [...] 7 8// --- 9 10// Choose the "node" implementation explicitly. 11//=> ! NOTE ! Will break in browser environments! 12import { random } from '@lukeed/csprng/node'; 13 14const array = random(1024); 15//=> <Buffer ...>
Returns: Buffer
or Uint8Array
Returns a typed array of given length
.
Type: Number
The desired length of your output TypedArray.
MIT © Luke Edwards
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 0/15 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
detected GitHub workflow tokens with excessive permissions
Details
Reason
no SAST tool detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
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
Score
Last Scanned on 2025-07-07
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