Files
Basilosaurusrex f027651f9b main repo
2025-11-24 18:09:40 +01:00

14 lines
369 B
JavaScript

// http://www.cse.yorku.ca/~oz/hash.html
export function djb2Hash(str) {
let hash = 5381;
for(let i = 0; i < str.length; i++){
const char = str.charCodeAt(i);
hash = (hash << 5) + hash + char;
}
return Math.abs(hash);
}
export function hexHash(str) {
return djb2Hash(str).toString(36).slice(0, 5);
}
//# sourceMappingURL=hash.js.map