Skip to content

Instantly share code, notes, and snippets.

@waghcwb
Created Sep 24, 2019
Embed
What would you like to do?
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