File size: 377 Bytes
64d3841
 
76d4779
 
5da61b4
76d4779
5da61b4
76d4779
 
1
2
3
4
5
6
7
8
9
10
import * as crypto from "crypto";

export async function sha256(input: string): Promise<string> {
	const utf8 = new TextEncoder().encode(input);
	const hashBuffer = await crypto.subtle.digest("SHA-256", utf8);
	const hashArray = Array.from(new Uint8Array(hashBuffer));
	const hashHex = hashArray.map((bytes) => bytes.toString(16).padStart(2, "0")).join("");
	return hashHex;
}