Created
August 30, 2020 03:58
-
-
Save keitakn/5f9d1f018dd5661998ea3fbe98621af9 to your computer and use it in GitHub Desktop.
JavaScriptブラウザ側だけでHashを生成する
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
| 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