hash string
This commit is contained in:
parent
ec1428cf6a
commit
a2e8c66f87
1 changed files with 10 additions and 0 deletions
|
|
@ -16,3 +16,13 @@ function loadTemplateAsync(path) {
|
|||
|
||||
return result
|
||||
}
|
||||
|
||||
async function hash(string) {
|
||||
const utf8 = new TextEncoder().encode(string)
|
||||
const hashBuffer = await crypto.subtle.digest('SHA-256', utf8)
|
||||
const hashArray = Array.from(new Uint8Array(hashBuffer))
|
||||
const hashHex = hashArray
|
||||
.map(bytes => bytes.toString(16).padStart(2, '0'))
|
||||
.join('')
|
||||
return hashHex
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue