Untitled

 avatar
unknown
plain_text
a year ago
347 B
3
Indexable
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
}
Editor is loading...
Leave a Comment