1 | // Copyright (c) Microsoft Corporation.
|
2 | // Licensed under the MIT license.
|
3 | import { encodeUTF8 } from "./encode";
|
4 | import { globalCrypto } from "./globalCrypto";
|
5 | export async function digest(str) {
|
6 | const data = encodeUTF8(str);
|
7 | const hash = await globalCrypto.subtle.digest("SHA-256", data);
|
8 | return bufferToHex(hash);
|
9 | }
|
10 | function bufferToHex(buffer) {
|
11 | return Array.prototype.map
|
12 | .call(new Uint8Array(buffer), (item) => ("00" + item.toString(16)).slice(-2))
|
13 | .join("");
|
14 | }
|
15 | //# sourceMappingURL=digest.browser.js.map |
\ | No newline at end of file |