Diffinery

codician/diffinerypublic

Open-source, agent-first GitHub and GitHub Actions alternative that runs on your own Cloudflare account: git hosting, pull requests, code review and drop-in GitHub Actions YAML on Workers, Durable Objects, R2 and Containers.

15 lines · 551 BRaw History
1import { toHex } from "./bytes.js";
2
3/** SHA-1 using WebCrypto (available in Workers and Node 20+). */
4export async function sha1(data: Uint8Array): Promise<Uint8Array> {
5 const digest = await crypto.subtle.digest("SHA-1", data as BufferSource);
6 return new Uint8Array(digest);
7}
8
9export async function sha1Hex(data: Uint8Array): Promise<string> {
10 return toHex(await sha1(data));
11}
12
13export async function sha256Hex(data: Uint8Array): Promise<string> {
14 return toHex(new Uint8Array(await crypto.subtle.digest("SHA-256", data as BufferSource)));
15}