Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@lukeed/csprng
Advanced tools
Readme
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
// Rely on bundlers/environment detection
import { random } from '@lukeed/csprng';
const array = random(12);
// browser => Uint8Array(12) [...]
// Node.js => <Buffer ...>
Specific Environment
// Choose the "browser" implementation explicitly.
//=> ! NOTE ! Will break in Node.js environments!
import { random } from '@lukeed/csprng/browser';
const array = random(1024);
//=> Uint8Array(1024) [...]
// ---
// Choose the "node" implementation explicitly.
//=> ! NOTE ! Will break in browser environments!
import { random } from '@lukeed/csprng/node';
const array = random(1024);
//=> <Buffer ...>
Returns: Buffer
or Uint8Array
Returns a typed array of given length
.
Type: Number
The desired length of your output TypedArray.
MIT © Luke Edwards
FAQs
An alias package for `crypto.randomBytes` in Node.js and/or browsers
The npm package @lukeed/csprng receives a total of 3,097,653 weekly downloads. As such, @lukeed/csprng popularity was classified as popular.
We found that @lukeed/csprng 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.