UNPKG

1.3 kBSource Map (JSON)View Raw
1{"version":3,"file":"digest.browser.js","sourceRoot":"","sources":["../../../src/utils/digest.browser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,GAAW;IACtC,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;IAC7B,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAC/D,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED,SAAS,WAAW,CAAC,MAAmB;IACtC,OAAO,KAAK,CAAC,SAAS,CAAC,GAAG;SACvB,IAAI,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SACpF,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { encodeUTF8 } from \"./encode\";\nimport { globalCrypto } from \"./globalCrypto\";\n\nexport async function digest(str: string): Promise<string> {\n const data = encodeUTF8(str);\n const hash = await globalCrypto.subtle.digest(\"SHA-256\", data);\n return bufferToHex(hash);\n}\n\nfunction bufferToHex(buffer: ArrayBuffer): string {\n return Array.prototype.map\n .call(new Uint8Array(buffer), (item: number) => (\"00\" + item.toString(16)).slice(-2))\n .join(\"\");\n}\n"]}
\No newline at end of file