Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | /** |
| 2 | * djb2 string hash (seed 5381, xor variant), normalized to a non-negative |
| 3 | * 32-bit integer. Callers pick their own string encoding (hex, base36, ...). |
| 4 | */ |
| 5 | export const djb2Hash = (value: string): number => { |
| 6 | let hash = 5381; |
| 7 | for (let index = 0; index < value.length; index += 1) { |
| 8 | hash = (hash * 33) ^ value.charCodeAt(index); |
| 9 | } |
| 10 | return Math.abs(hash >>> 0); |
| 11 | }; |