djb2
Calculates the hash of a string using the djb2 algorithm.
Syntax
typescript
djb2(str: string): numberParameters
| Name | Type | Description |
|---|---|---|
str | string | The string to be processed |
Returns
| Type | Description |
|---|---|
number | The calculated hash value (unsigned 32 bits) |
Example
typescript
djb2("hello"); // 210714636441Notes
- Throws a
TypeErrorif the value is not a string. - The djb2 algorithm is simple and fast, but not secure for cryptographic use.
