Hash
Edit on GitHubUtilities for hashing any value.
Added in 0.1.0
No other changes yet.
1 | let hashInstance = Hash.make() |
1 | let hashInstance = Hash.makeSeeded(10) |
Types
Type declarations included in the Hash module.
Hash.HashInstance
Added in 0.7.0
No other changes yet.
Represents a particular hashing instance.
Values
Functions and constants included in the Hash module.
Hash.make
Added in 0.7.0
No other changes yet.
Produces a generic hash instance using a random seed value.
Returns:
type | description |
---|---|
HashInstance |
A hashing instance that can be consumed during hashing |
Throws:
Failure(String)
- If WASI random_get fails
Examples:
1 | let hashInstance = Hash.make() |
Hash.makeSeeded
Added in 0.7.0
No other changes yet.
Produces a hashInstance using the given seed.
Parameters:
param | type | description |
---|---|---|
seed |
Number |
The seed to use while hashing |
Returns:
type | description |
---|---|
HashInstance |
A hashing instance that can be consumed during hashing |
Examples:
1 | let hashInstance = Hash.makeSeeded(1) |
1 | let hashInstance1 = Hash.makeSeeded(1) |
Hash.hash
Added in 0.1.0
version | changes |
---|---|
0.7.0 | Added `hashInstance` parameter instead of using a global seed |
A generic hash function that produces an integer from any value given a hashing instance. If a == b
then Hash.hash(h, a) == Hash.hash(h, b)
.
Parameters:
param | type | description |
---|---|---|
hashInstance |
HashInstance |
The hashing instance to use as a seed |
anything |
a |
The value to hash |
Returns:
type | description |
---|---|
Number |
A hash for the given value |
Examples: