Closed wk3368 closed 2 years ago
sha512: async (message: Uint8Array): Promise<Uint8Array> => { if (crypto.web) { const buffer = await crypto.web.subtle.digest('SHA-512', message.buffer); return new Uint8Array(buffer); } else if (crypto.node) { return Uint8Array.from(crypto.node.createHash('sha512').update(message).digest()); } else { throw new Error("The environment doesn't have sha512 function"); } },
because
why not delete the crypto.web one, and make it a sync function?
sha512: (message: Uint8Array): Uint8Array => { return Uint8Array.from(crypto.node.createHash('sha512').update(message).digest()); },
There is no require("crypto") in browsers. It is node.js-only. If your build tool adds require("crypto"), it is non-standard.
because
why not delete the crypto.web one, and make it a sync function?