dao-game / files / src / utils / hashing.ts
hashing.ts
| 1 | export 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 | } |