Docs / Randomness

Glossary: StableHash

The methods of StableHash, in alphabetical order.

Color legend method

Hashes that are the same on every run, platform and .NET version, unlike string.GetHashCode(), which is randomized per process.

A static class. The seeds and forks page shows it in context, with code.

Names are colored by what they are: a method.

Methods

Combine() →

Combine(ulong a, ulong b) · Static. A hash of the two numbers, in that order: Combine(a, b) and Combine(b, a) differ. Rng.Fork combines the parent’s seed with the key, then with the index.

Parameter Type Description
a ulong The first number, such as a seed.
b ulong The second number, such as a key’s hash or an index.

Mix() →

Mix(ulong z) · Static. The SplitMix64 finalizer: spreads the bits of the number, so close inputs give far outputs, and no two inputs give the same output. Mix(0) is 0.

Parameter Type Description
z ulong The number to mix.

Of() →

Of(string text) · Static. A hash of the text: FNV-1a 64 over its UTF-16 characters, then Mix. Every character and its case count. Throws ArgumentNullException for null.

Parameter Type Description
text string The text to hash, such as a fork key or a seed the player typed.