Socket
Socket
Sign inDemoInstall

random-bytes

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

random-bytes

URL and cookie safe UIDs


Version published
Maintainers
1
Weekly downloads
1,864,485
decreased by-16.51%
Bundle size
492 bytes
Minified + gzipped

Weekly downloads

Readme

Source

random-bytes

NPM Version NPM Downloads Node.js Version Build Status Test Coverage

Generate strong pseudo-random bytes.

This module is a simple wrapper around the Node.js core crypto.randomBytes API, with the following additions:

  • A Promise interface for environments with promises.
  • For Node.js versions that do not wait for the PRNG to be seeded, this module will wait a bit.

Installation

$ npm install random-bytes

API

var randomBytes = require('random-bytes')

randomBytes(size, callback)

Generates strong pseudo-random bytes. The size argument is a number indicating the number of bytes to generate.

randomBytes(12, function (error, bytes) {
  if (error) throw error
  // do something with the bytes
})

randomBytes(size)

Generates strong pseudo-random bytes and return a Promise. The size argument is a number indicating the number of bytes to generate.

Note: To use promises in Node.js prior to 0.12, promises must be "polyfilled" using global.Promise = require('bluebird').

randomBytes(18).then(function (string) {
  // do something with the string
})

randomBytes.sync(size)

A synchronous version of above.

var bytes = randomBytes.sync(18)

License

MIT

Keywords

FAQs

Last updated on 17 Jan 2016

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