-
-
Save rm--/c1d9d73d0496fd83f8cc8200ee8b7f0f to your computer and use it in GitHub Desktop.
sha512 digest to int
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function digestMessage(message) { | |
const encoder = new TextEncoder(); | |
const data = encoder.encode(message); | |
const hash = await crypto.subtle.digest('SHA-512', data); | |
return hash; | |
} | |
digestMessage('input') | |
.then(digestBuffer => console.log(new DataView(digestBuffer).getUint32())); | |
3698158640 | |
https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment