1// Alchemy modifications are licensed under Apache-2.0.
2// This file includes third-party code; see /THIRD_PARTY_LICENSES.md.
3export async function computeHash(value: string) {
4 const msgUint8 = new TextEncoder().encode(value); // encode as (utf-8) Uint8Array
5 const hashBuffer = await crypto.subtle.digest("SHA-1", msgUint8); // hash the message
6 const hashArray = Array.from(new Uint8Array(hashBuffer)); // convert buffer to byte array
7 const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join(""); // convert bytes to hex string
8
9 return hashHex;
10}