param byteLength param forceLength throws returns export function randBytes ( byteLength , forceLength = false ) { if ( byteLength < 1 ) throw new RangeError ( 'byteLength MUST be > 0' ) ; return new Promise ( function ( resolve , reject ) { if ( ! IS_BROWSER ) { const crypto = require ( 'crypto' ) ; crypto . randomBytes ( byteLength , function ( err , buf ) { if ( err !== null ) reject ( err ) ; if ( forceLength ) buf [ 0 ] = buf [ 0 ] | 128 ; resolve ( buf ) ; } ) ; } else { const buf = new Uint8Array ( byteLength ) ; self . crypto . getRandomValues ( buf ) ; if ( forceLength ) buf [ 0 ] = buf [ 0 ] | 128 ; resolve ( buf ) ; } } ) ; } param byteLength param forceLength throws returns export function randBytesSync ( byteLength , forceLength = false ) { if ( byteLength < 1 ) throw new RangeError ( 'byteLength MUST be > 0' ) ; if ( ! IS_BROWSER ) { const crypto = require ( 'crypto' ) ; const buf = crypto . randomBytes ( byteLength ) ; if ( forceLength ) buf [ 0 ] = buf [ 0 ] | 128 ; return buf ; } else { const buf = new Uint8Array ( byteLength ) ; self . crypto . getRandomValues ( buf ) ; if ( forceLength ) buf [ 0 ] = buf [ 0 ] | 128 ; return buf ; } }