mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-01 13:47:06 +01:00
290353da9b
* 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
12 lines
314 B
TypeScript
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('');
|
|
}
|