1
2
3
4
5
6
7
8
import { Buffer } from "buffer";
export const randomBytes = (len, cb) => {
if (cb) throw "async not supported";
const arr = new Uint8Array(len);
self.crypto.getRandomValues(arr);
return Buffer.from(arr.buffer, arr.byteOffset, arr.byteLength);
};