1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 02:10:12 +01:00
metamask-extension/shared/modules/hash.utils.ts
António Regadas 290353da9b
[MMI] interactive replacement token notification (#18620)
* adds the component and styles

* adds tests

* story file update

* clean up

* lint and prettier

* lint & prettier fix

* adds review changes

* adds necessary dependencies

* runs lint and prettier
2023-04-21 09:58:03 +01:00

12 lines
314 B
TypeScript

/* eslint-disable no-undef */
export async function sha256(str: string): Promise<string> {
const buf = await crypto.subtle.digest(
'SHA-256',
new TextEncoder().encode(str),
);
return Array.prototype.map
.call(new Uint8Array(buf), (x: number) => `00${x.toString(16)}`.slice(-2))
.join('');
}