返回 DeepSeek-Reasonix
stableStringHash.ts
根目录 / desktop / frontend / src / lib / stableStringHash.ts
1 // Small deterministic hash for UI keys; collisions are still namespaced by the
2 // source segment id and this avoids shipping a crypto implementation.
3 export function stableStringHash(value: string): string {
4 let hash = 2166136261;
5 for (let i = 0; i < value.length; i += 1) {
6 hash ^= value.charCodeAt(i);
7 hash = Math.imul(hash, 16777619);
8 }
9 return (hash >>> 0).toString(36);
10 }
11
11 lines TYPESCRIPT