aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-02-28 15:24:38 -0800
committerAdam Soltys <[email protected]>2026-02-28 15:24:38 -0800
commit8c22f68085eab269d4d1ad220c9d5b2db3096fb1 (patch)
tree951ab208e82f0a4a3635fc675cf655a71006d46e /src/lib
parentdc92cf377f52e5f165020ea5a8407a14d279264c (diff)
downloadcoinos-ui-8c22f68085eab269d4d1ad220c9d5b2db3096fb1.tar.gz
coinos-ui-8c22f68085eab269d4d1ad220c9d5b2db3096fb1.zip
hash pins
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/utils.ts5
1 files changed, 4 insertions, 1 deletions
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<string, string> => {
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) =>