From 8c22f68085eab269d4d1ad220c9d5b2db3096fb1 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 28 Feb 2026 15:24:38 -0800 Subject: hash pins --- src/lib/utils.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/lib') diff --git a/src/lib/utils.ts b/src/lib/utils.ts index e37556e3..7a4030d5 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -2,7 +2,8 @@ import { browser } from "$app/environment"; import { goto } from "$app/navigation"; import { page } from "$app/stores"; import { PUBLIC_COINOS_NETWORK, PUBLIC_COINOS_URL } from "$env/static/public"; -import { bytesToHex } from "@noble/hashes/utils.js"; +import { sha256 } from "@noble/hashes/sha2.js"; +import { bytesToHex, utf8ToBytes } from "@noble/hashes/utils.js"; import { fail as svelteFail, redirect } from "@sveltejs/kit"; import { toast } from "@zerodevx/svelte-toast"; import { @@ -31,6 +32,8 @@ const ipHeaders = (): Record => { return ip ? { "cf-connecting-ip": ip } : {}; }; +export const hashPin = (pin: string) => bytesToHex(sha256(utf8ToBytes(pin))); + export const punk = (k: string) => `${Math.floor((parseInt(k.slice(-2), 16) / 256) * 64) + 1}.webp`; export const g = (url: string, fetch: any, headers: object) => -- cgit v1.2.3