Created
September 24, 2019 12:41
-
-
Save waghcwb/1b21da6c0e86784c4cd04ec69c5a65c7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 sha256 = async message => { | |
const msgBuffer = new TextEncoder('utf-8').encode(message); | |
const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer); | |
const hashArray = Array.from(new Uint8Array(hashBuffer)); | |
return hashArray.map(b => ('00' + b.toString(16)).slice(-2)).join(''); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment