Remove unused x-noble-hashes functions (#1275)

This commit is contained in:
Jaco
2021-12-02 08:48:44 +02:00
committed by GitHub
parent 9ce825de94
commit dc63304735
-19
View File
@@ -152,22 +152,3 @@ export function wrapConstructorWithOpts<H extends Hash<H>, T extends Object>(
hashC.init = hashC.create;
return hashC;
}
export const crypto: { node?: any; web?: any } = (() => {
const webCrypto = typeof self === 'object' && 'crypto' in self ? self.crypto : undefined;
const nodeRequire = typeof module !== 'undefined' && typeof require === 'function';
return {
node: nodeRequire && !webCrypto ? require('crypto') : undefined,
web: webCrypto,
};
})();
export function randomBytes(bytesLength = 32): Uint8Array {
if (crypto.web) {
return crypto.web.getRandomValues(new Uint8Array(bytesLength));
} else if (crypto.node) {
return new Uint8Array(crypto.node.randomBytes(bytesLength).buffer);
} else {
throw new Error("The environment doesn't have randomBytes function");
}
}