ethers.js/lib.esm/crypto/random.js

19 lines
564 B
JavaScript
Raw Normal View History

2022-09-05 23:57:11 +03:00
import { randomBytes as crypto_random } from "./crypto.js";
let locked = false;
const _randomBytes = function (length) {
return new Uint8Array(crypto_random(length));
};
let __randomBytes = _randomBytes;
export function randomBytes(length) {
return __randomBytes(length);
}
randomBytes._ = _randomBytes;
randomBytes.lock = function () { locked = true; };
randomBytes.register = function (func) {
if (locked) {
throw new Error("random is locked");
}
__randomBytes = func;
};
Object.freeze(randomBytes);
//# sourceMappingURL=random.js.map