Eightomic
Dissection

Hash 32 A

It's the fastest 32-bit, OAAT hashing algorithm versus CDB and DJB2.

Algorithm

Source

#include <stdint.h> uint32_t eightomic_hash_32_a(const unsigned long input_count, const uint8_t *input) { uint32_t mix = 111111; unsigned long i = 0; while (i < input_count) { mix = (input[i] ^ mix) - ((mix << 25) | (mix >> 7)); i++; } return mix; }

License

It's free and open source.

Reference

eightomic_hash_32_a() is the hashing function that accepts the following 2 arguments in left-to-right order.

1: input_count is the const unsigned long count of elements in the input array.

2: input is the const uint8_t array to hash.

The return value data type is uint32_t.

It returns the 32-bit unsigned integer hash digest result.

Explanation

It has equivalent or faster speeds than CDB and DJB2 at all input sizes.

Both CDB and DJB2 have between 100% and 200000% more collisions across all SMHasher tests relevant to generalized, high-throughput, non-adversarial hashing.

Auxiliary seed input isn't a strict requirement for non-cryptographic hashing algorithms, but Eightomic is developing and testing an improved version that accepts a 32-bit seed integer when implementations require it.

The hash function expression has faster speeds and stronger collision test results among dozens of similar expressions.

The non-prime initialization value 111111 is selected at an offset length between 16 and 32 bits with superior test results compared to every other combination of repeated 1 digits at different lengths.

Furthermore, all other shift rotation operand values yield inferior test results compared to 25 and 7.

When faster speeds are required instead of lower collisions, removing the mix XOR operand results in faster speed by a small margin with the tradeoff of either truncating digests to a few bits or hashing pre-tested input sets that aren't expected to change, such as country codes or specific ID formats.

API

Quantum

Quantum

Spawn non-deterministic, quantum-aligned randomness with an optimal, unique QRNG API.