Created
October 26, 2022 16:16
-
-
Save danielearwicker/e54432a46e51307d947390a396c2b92f to your computer and use it in GitHub Desktop.
Getting base64 string of SHA-256 from some string input, natively in modern browsers
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
const message = "Hello, this is the message"; | |
const hash = new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode(message))); | |
const base64 = btoa(String.fromCharCode(...hash))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment