Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
347 B
1
Indexable
Never
function fnvHash(data: string, prime: number = 0x811C9DC5, offset: number = 0): number {
  let hash = offset;
  for (let char of data) {
    const charCode = char.charCodeAt(i);
    hash = (hash * prime) ^ charCode;
    hash = hash & 0xffffffff; // Convert to 32-bit unsigned integer
  }
  return hash >>> 0; // Make sure the output is positive
}
Leave a Comment