Package Exports
- pure-randombytes
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pure-randombytes) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
randombytes
Get secure cryptographic random bytes from of any TypedArray, ArrayBuffer or size without importing node:crypto or node:buffer to browsers.
import randomBytes from 'pure-randombytes'
randomBytes() // return Uint8(20) - default to 20 (same as sha1 length)
randomBytes(16) // return Uint8(16)
randomBytes("10") // return Uint8(16) - Anything that isn't TypedArray is casted to Number(x)Still want to get a randomized node:buffer back or have something pre allocated? Stuff it in as the first argument, and get the same instance back
randomBytes(uint8) === uint8 // works with pre allocated buffer
randomBytes(bigInt64_or_dataView) // ...and any kind of ArrayBufferView
randomBytes(new ArrayBuffer(33)) instanceof ArrayBuffer // ...ArrayBuffer
randomBytes(Buffer.allocUnsafe(20)) instanceof Buffer // ...and yes, Buffer as well