npm

Need private packages and team management tools?Check out npm Orgs. »

random-poly-fill

1.0.1 • Public • Published

random-poly-fill

A polyfill for crypto.randomFill and crypto.randomFillSync from Node.js core.

These two functions were added in Node.js v6.13.0. Use this polyfill if you need to use these function in older versions of Node.js.

This polyfill is not optimized for speed or low resource usage. If you can, use crypto.randomBytes directly instead.

npm build status js-standard-style

Installation

npm install random-poly-fill --save

Usage

const { randomFill, randomFillSync } = require('random-poly-fill')
 
const source = Buffer.alloc(10)
 
randomFill(source, 0, 5, function (err, target) {
  if (err) throw err
  console.log(source.toString('hex')) // fc4584c64a0000000000
  console.log(target.toString('hex')) // fc4584c64a0000000000
})
 
const buf = Buffer.alloc(10)
 
randomFillSync(buf, 5, 5)
 
console.log(buf.toString('hex')) // 0000000000bcc09d5877

API

crypto.randomFill(buffer[, offset][, size], callback)

See Node.js core documentation for crypto.randomFill.

crypto.randomFillSync(buffer[, offset][, size])

See Node.js core documentation for crypto.randomFillSync.

License

MIT

install

npm i random-poly-fill

Downloadsweekly downloads

44,649

version

1.0.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability