chensenlai 10988628a0 语音房项目初始化 | 5 rokov pred | |
---|---|---|
.. | ||
HISTORY.md | 5 rokov pred | |
LICENSE | 5 rokov pred | |
README.md | 5 rokov pred | |
index.js | 5 rokov pred | |
package.json | 5 rokov pred |
Generate strong pseudo-random bytes.
This module is a simple wrapper around the Node.js core crypto.randomBytes
API,
with the following additions:
Promise
interface for environments with promises.$ npm install random-bytes
var randomBytes = require('random-bytes')
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
})
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
})
A synchronous version of above.
var bytes = randomBytes.sync(18)