Skip to content

Instantly share code, notes, and snippets.

@keitakn
Created August 30, 2020 03:58
Show Gist options
  • Select an option

  • Save keitakn/5f9d1f018dd5661998ea3fbe98621af9 to your computer and use it in GitHub Desktop.

Select an option

Save keitakn/5f9d1f018dd5661998ea3fbe98621af9 to your computer and use it in GitHub Desktop.
JavaScriptブラウザ側だけでHashを生成する
async function sha256(text){
const uint8 = new TextEncoder().encode(text)
const digest = await crypto.subtle.digest('SHA-256', uint8)
return Array.from(new Uint8Array(digest)).map(v => v.toString(16).padStart(2,'0')).join('')
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment