deno.land / x / lume@v2.1.4 / core / utils / digest.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { crypto } from "../../deps/crypto.ts";import { encodeHex } from "../../deps/hex.ts";
const decoder = new TextDecoder();const encoder = new TextEncoder();
/** Digest a message using SHA-1 algorithm */export async function sha1(message: string | Uint8Array): Promise<string> { if (typeof message === "string") { message = encoder.encode(message); }
const hash = await crypto.subtle.digest("SHA-1", message); return decoder.decode(hash);}
/** Digest a message using MD5 algorithm */export async function md5(message: string | Uint8Array): Promise<string> { if (typeof message === "string") { message = encoder.encode(message); }
const hash = await crypto.subtle.digest("MD5", message); return encodeHex(hash);}
lume

Version Info

Tagged at
7 months ago