Files
2026-07-13 12:08:39 +08:00

9 lines
275 B
TypeScript

/** Non-cryptographic hash for cache keys and display purposes — do not use for security. */
export function strToHash(str: string): number {
let hash = 0;
for (let i = 0; i < str.length; i++) {
hash = str.charCodeAt(i) + ((hash << 5) - hash);
}
return hash;
}