Socket
Socket
Sign inDemoInstall

crng

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    crng

Generate random values from a crypto RNG source


Version published
Weekly downloads
1
Maintainers
1
Created
Weekly downloads
 

Readme

Source

crng

Generate random values from a cryptographicaly-secure random number generator in Node.js. Uses the crypto module.

Generators

cryptoRandom01

Generate a value between 0 (inclusive) and 1 (exclusive).

import {cryptoRandom01} from "crng";
// const {cryptoRandom01} = require("crng");

let val: number = cryptoRandom01();

cryptoRandomDouble

Generate a number that is not infinite and not NaN.

import {cryptoRandomDouble} from "crng";
// const {cryptoRandomDouble} = require("crng");

let val: number = cryptoRandomDouble();

cryptoRandomHex

Generate a string containing hexadecimal characters with n bytes of entropy (defaults to 8).

Note that the length of the resulting value is double the entropy amount.

import {cryptoRandomHex} from "crng";
// const {cryptoRandomHex} = require("crng");

let val: string = cryptoRandomHex(8);
console.assert(val.length === 16);

Keywords

FAQs

Last updated on 03 Aug 2018

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc