export function isUint8Array ( value ) { return Object . prototype . toString . call ( value ) === "[object Uint8Array]" ; } type RandomBytesFunction = ( size : number ) => Uint8Array ; export const randomBytes = function insecureRandomBytes ( size ) { const result = Buffer . alloc ( size ) ; for ( let i = 0 ; i < size ; ++ i ) result [ i ] = Math . floor ( Math . random ( ) * 256 ) ; return result ; } ;