js-libp2p-crypto/src/random-bytes.js

14 lines
287 B
JavaScript
Raw Normal View History

2017-07-22 13:25:15 -07:00
'use strict'
const rsa = require('./keys/rsa')
function randomBytes (number) {
if (!number || typeof number !== 'number') {
throw new Error('first argument must be a Number bigger than 0')
}
return rsa.getRandomValues(new Uint8Array(number))
}
module.exports = randomBytes