get-random-byte
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Get random byte

Get a single, cryptographically strong, random byte.

This module uses an internal cache to minimize calls against the crypto backend. When the cache is empty, a large number of bytes is requested and handed out one by one. The perfomance benefits of this can be seen in this jsPerf test case.

Installation

npm install --save get-random-byte

Usage

const getRandomByte = require('get-random-byte')

console.log(getRandomByte())
//=> 112

console.log(getRandomByte())
//=> 143

console.log(getRandomByte())
//=> 205

API

getRandomByte(): number

Return a cryptographically strong random integer between 0 and 255 (inclusivly).

Readme

Keywords

none

Package Sidebar

Install

npm i get-random-byte

Weekly Downloads

0

Version

1.0.1

License

MIT

Last publish

Collaborators

  • linusu