ctrl + k
On This Page
Functions
Crypto Utilities
The Crypto utilities provide functions for generating unique identifiers and hash codes in JavaScript. These functions are useful for creating unique keys, generating consistent hashes for objects, and other cryptographic purposes.
Functions
hashCode
Generates a hash code for the given input using an adapted UMASH algorithm.
Collision Resistance This is based on the UMASH algorithm which provides good performance and collission resistance.
Parameters
Name | Type | Description |
---|---|---|
input | any | The value to hash |
options | object | Optional configuration |
Options
Name | Type | Default | Description |
---|---|---|---|
prettify | boolean | false | If true, returns a prettified string representation |
seed | number | 0x12345678 | Seed value for the hash function |
Returns
A 32-bit integer hash code, or a prettified string if prettify
is true.
Example
generateID
Generates a unique identifier.
Returns
A string representing a unique identifier.
Example
prettifyID
Converts a number into a more readable string representation.
Parameters
Name | Type | Description |
---|---|---|
num | number | The number to convert |
Returns
A string representation of the number using alphanumeric characters.