polynomialHash
Computes a 31-based polynomial rolling hash of the input string,
and returns a base36-encoded identifier of the given length.
This method mimics the behavior of Java's String.hashCode(),
ensuring fast, deterministic, and compact hash generation.
Note: This hash is not cryptographically secure, and is best suited
for quick identification or lookup purposes (e.g. cache keys, short IDs).
Signature
const polynomialHash: (target: string, length?: number) => string
Parameters
| Name | Type | Description |
|---|---|---|
target | - | The input string to hash. |
length | - | Desired length of the result identifier (default: 7, max: 7). |
Returns
A base36-encoded hash string of the specified length.