social bookmarking for atproto
at main 565 B view raw
1/* 2 * clippr: a social bookmarking service for the AT Protocol 3 * Copyright (c) 2025 clippr contributors. 4 * SPDX-License-Identifier: AGPL-3.0-only 5 */ 6 7import xxhash from "xxhash-wasm"; 8 9/// Hash a given string into a hexadecimal xxh64 string. 10export async function hashString(data: string): Promise<string> { 11 const { h64 } = await xxhash(); 12 return h64(data).toString(16); 13} 14 15/// Check if a string is equivalent to a given hash. 16export async function validateHash( 17 data: string, 18 hash: string, 19): Promise<boolean> { 20 return hash === (await hashString(data)); 21}