MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / stringHash

Function stringHash

apps/start/src/components/facehash/utils/hash.ts:8–16  ·  view source on GitHub ↗
(str: string)

Source from the content-addressed store, hash-verified

6 * @returns A positive 32-bit integer hash
7 */
8export function stringHash(str: string): number {
9 let hash = 0;
10 for (let i = 0; i < str.length; i++) {
11 const char = str.charCodeAt(i);
12 hash = (hash << 5) - hash + char;
13 hash &= hash; // Convert to 32bit integer
14 }
15 return Math.abs(hash);
16}

Callers 1

facehash.tsxFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected