fuzzyworld

dao-game / react / files / src / utils / hashing.ts

Branch react · default branch · all branches

hashing.ts

Blame: the commit that last changed each line · file · history

38c7e27c 2022-03-22 Pavel Safronov1export function generateHash(text: string) {
2 var hash = 0;
3 if (text.length == 0) {
4 return hash;
5 }
6 for (let i = 0; i < text.length; i++) {
7 var charCode = text.charCodeAt(i);
8 hash = (hash << 7) - hash + charCode;
9 hash = hash & hash;
10 }
11 return hash;
12}