Co-authored-by: Chaim Lev-Ari <chaim.lev-ari@portainer.io> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
9 lines
275 B
TypeScript
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;
|
|
}
|