How to use the randomBytesAsync function from crypto
Find comprehensive JavaScript crypto.randomBytesAsync code examples handpicked from public code repositorys.
GitHub: schmich/litepoll
2 3 4 5 6 7 8 9 10 11
var crypto = Promise.promisifyAll(require('crypto')); function createKey() { return new Promise(function(resolve, reject) { co.wrap(function *() { var bytes = yield crypto.randomBytesAsync(33); var key = bytes.toString('base64').replace(/\+/g, '-').replace(/\//g, '_'); resolve(key); })(); });
0
6
3
GitHub: Unrealomega/phoenix
32 33 34 35 36 37 38 39 40 41
return result.rows[0] || Promise.reject(new Error('No media available with that hash.')); }); } function upload(uploadStream) { return crypto.randomBytesAsync(15).then(function (bytes) { var hash = crypto.createHash('sha256'); var temporaryPath = path.join(temporaryDirectory, bytes.toString('base64').replace(/\//g, '-')); var temporaryFileStream = fs.createWriteStream(temporaryPath, { flags: 'wx', mode: 6 << 6 }); var identifyStream = new IdentifyStream();
6
0
1
GitHub: truemrwalker/wblwrld3
79 80 81 82 83 84 85
* Returns a buffer with the specified number of random bytes. * @param {number} nBytes - The number of random bytes to generate. * @returns {Promise} A promise that is resolved with a buffer containing nBytes random bytes. */ module.exports.randomBytesAsync = function(nBytes) { return crypto.randomBytesAsync(nBytes); };
3
5
3
GitHub: FoodMob/FoodMob-Node
10 11 12 13 14 15 16 17 18 19
//Convert Crypto functions to user Promises Promise.promisifyAll(Crypto); //Promise function to return random salt function generateSalt() { return Crypto.randomBytesAsync(256); } //Promise function to return a random auth token function generateAuthToken() {
1
1
3
+ 3 other calls in file
GitHub: theQRL/wiki
115 116 117 118 119 120 121 122 123 124
description: '', robots: ['index', 'follow'], analyticsService: '', analyticsId: '' }) _.set(WIKI.config, 'sessionSecret', (await crypto.randomBytesAsync(32)).toString('hex')) _.set(WIKI.config, 'telemetry', { isEnabled: req.body.telemetry === true, clientId: uuid() })
0
0
3
crypto.createHash is the most popular function in crypto (882 examples)