This page looks at some non-cryptographic hash designs. The hashes are from n-bit inputs to n-bit outputs. These are mainly for use with PRNG designs.

# Methodology

Our goal is to find functions that are good at mixing/diffusing.

## Evaluation

We will evaluate how the functions behave using an avalanche diagram. An avalanche diagram is a graph that displays the probability of each output bit flipping in response to each input bit flipping. It allows us to quickly see if the function has any terrible biases.

## Design criteria

It is not difficult to make a good hash function by combining a lot of subdiffusions. What we want is to achieve good mixing with the smallest number of operations. Pretty much all uses cases of non-cryptographic hash functions need to execute quickly and consume minimal resources.

# Algorithms

## Identity function

The identity function (`f(x) = x`) does not modify the input value, so each bit only affects itself. This cannot be considered a hash function by any means, but serves as a nice sanity check to see if the graph is what we expect.

In [2]:
```%%cython

ctypedef unsigned long long u64

cpdef u64 identity_function(u64 x):
return x```
In [3]:
`plot_hash(identity_function)`
Out:

## Non-deterministic random values

On the opposite end of the spectrum, we completely throw out determinism and just use real random numbers.

In [4]:
```def urandom64(x):
return int.from_bytes(os.urandom(8), 'big')

plot_hash(urandom64)```
Out:
In [5]:
```def urandom32(x):
return int.from_bytes(os.urandom(4), 'big')

plot_hash(urandom32, bits=32)```
Out:

## Multiplication with a large prime

In [6]:
```%%cython

ctypedef unsigned long long u64

cpdef u64 prime_multiplication(u64 x):
cdef u64 prime = 10115642443237858459;
return x * prime```
In [7]:
`plot_hash(prime_multiplication)`
Out:

## Rotate-XOR-Prime (rxprime)

This hash is based on multiplying the input by primes, and XORing it with rotated versions of itself.

### 32-bit rxprime

In [8]:
```%%cython

ctypedef unsigned char u8
ctypedef unsigned long u32

cdef u32 rotl32(u32 n, u8 k):
cdef u32 a = n << k
cdef u32 b = n >> (32 - k)
return a | b

cpdef u32 rxprime32(u32 x):
x *= 7919
x ^= rotl32(x, 7)
x *= 7723
x ^= rotl32(x, 11)
x *= 7561
x ^= rotl32(x, 13)
return x```
In [9]:
`plot_hash(rxprime32, bits=32)`
Out:

### 64-bit rxprime

In [10]:
```%%cython

ctypedef unsigned char u8
ctypedef unsigned long long u64

cdef u64 rotl64(u64 n, u8 k):
cdef u64 a = n << k
cdef u64 b = n >> (64 - k)
return a | b

cpdef u64 rxprime64(u64 x):
x *= 7919
x ^= rotl64(x, 7)
x *= 7723
x ^= rotl64(x, 11)
x *= 7561
x ^= rotl64(x, 13)
x *= 7411
x ^= rotl64(x, 17)
return x```
In [11]:
`plot_hash(rxprime64)`
Out:

## SplitMix64

In [24]:
```%%cython -a

ctypedef unsigned long long u64

cpdef u64 splitmix64(u64 x):
x ^= x >> 30
x *= <u64>0xbf58476d1ce4e5b9
x ^= x >> 27
x *= <u64>0x94d049bb133111eb
x ^= x >> 31
return x```
Out [24]:
```

Cython: _cython_magic_1df062dd335dea8b17c4f61033efc66b.pyx
body.cython{font-family:courier;font-size:12}.cython.line{margin:0em}.cython.code{font-size:9;color:#444444;display:none;margin:0px 0px 0px 8px;border-left:8px none}.cython.line .run{background-color:#B0FFB0}.cython.line .mis{background-color:#FFB0B0}.cython.code.run{border-left:8px solid #B0FFB0}.cython.code.mis{border-left:8px solid #FFB0B0}.cython.code .py_c_api{color:red}.cython.code .py_macro_api{color:#FF7000}.cython.code .pyx_c_api{color:#FF3000}.cython.code .pyx_macro_api{color:#FF7000}.cython.code .refnanny{color:#FFA000}.cython.code .trace{color:#FFA000}.cython.code .error_goto{color:#FFA000}.cython.code .coerce{color:#008000;border:1px dotted #008000}.cython.code .py_attr{color:#FF0000;font-weight:bold}.cython.code .c_attr{color:#0000FF}.cython.code .py_call{color:#FF0000;font-weight:bold}.cython.code .c_call{color:#0000FF}.cython.score-0{background-color:#FFFFff}.cython.score-1{background-color:#FFFFe7}.cython.score-2{background-color:#FFFFd4}.cython.score-3{background-color:#FFFFc4}.cython.score-4{background-color:#FFFFb6}.cython.score-5{background-color:#FFFFaa}.cython.score-6{background-color:#FFFF9f}.cython.score-7{background-color:#FFFF96}.cython.score-8{background-color:#FFFF8d}.cython.score-9{background-color:#FFFF86}.cython.score-10{background-color:#FFFF7f}.cython.score-11{background-color:#FFFF79}.cython.score-12{background-color:#FFFF73}.cython.score-13{background-color:#FFFF6e}.cython.score-14{background-color:#FFFF6a}.cython.score-15{background-color:#FFFF66}.cython.score-16{background-color:#FFFF62}.cython.score-17{background-color:#FFFF5e}.cython.score-18{background-color:#FFFF5b}.cython.score-19{background-color:#FFFF57}.cython.score-20{background-color:#FFFF55}.cython.score-21{background-color:#FFFF52}.cython.score-22{background-color:#FFFF4f}.cython.score-23{background-color:#FFFF4d}.cython.score-24{background-color:#FFFF4b}.cython.score-25{background-color:#FFFF48}.cython.score-26{background-color:#FFFF46}.cython.score-27{background-color:#FFFF44}.cython.score-28{background-color:#FFFF43}.cython.score-29{background-color:#FFFF41}.cython.score-30{background-color:#FFFF3f}.cython.score-31{background-color:#FFFF3e}.cython.score-32{background-color:#FFFF3c}.cython.score-33{background-color:#FFFF3b}.cython.score-34{background-color:#FFFF39}.cython.score-35{background-color:#FFFF38}.cython.score-36{background-color:#FFFF37}.cython.score-37{background-color:#FFFF36}.cython.score-38{background-color:#FFFF35}.cython.score-39{background-color:#FFFF34}.cython.score-40{background-color:#FFFF33}.cython.score-41{background-color:#FFFF32}.cython.score-42{background-color:#FFFF31}.cython.score-43{background-color:#FFFF30}.cython.score-44{background-color:#FFFF2f}.cython.score-45{background-color:#FFFF2e}.cython.score-46{background-color:#FFFF2d}.cython.score-47{background-color:#FFFF2c}.cython.score-48{background-color:#FFFF2b}.cython.score-49{background-color:#FFFF2b}.cython.score-50{background-color:#FFFF2a}.cython.score-51{background-color:#FFFF29}.cython.score-52{background-color:#FFFF29}.cython.score-53{background-color:#FFFF28}.cython.score-54{background-color:#FFFF27}.cython.score-55{background-color:#FFFF27}.cython.score-56{background-color:#FFFF26}.cython.score-57{background-color:#FFFF26}.cython.score-58{background-color:#FFFF25}.cython.score-59{background-color:#FFFF24}.cython.score-60{background-color:#FFFF24}.cython.score-61{background-color:#FFFF23}.cython.score-62{background-color:#FFFF23}.cython.score-63{background-color:#FFFF22}.cython.score-64{background-color:#FFFF22}.cython.score-65{background-color:#FFFF22}.cython.score-66{background-color:#FFFF21}.cython.score-67{background-color:#FFFF21}.cython.score-68{background-color:#FFFF20}.cython.score-69{background-color:#FFFF20}.cython.score-70{background-color:#FFFF1f}.cython.score-71{background-color:#FFFF1f}.cython.score-72{background-color:#FFFF1f}.cython.score-73{background-color:#FFFF1e}.cython.score-74{background-color:#FFFF1e}.cython.score-75{background-color:#FFFF1e}.cython.score-76{background-color:#FFFF1d}.cython.score-77{background-color:#FFFF1d}.cython.score-78{background-color:#FFFF1c}.cython.score-79{background-color:#FFFF1c}.cython.score-80{background-color:#FFFF1c}.cython.score-81{background-color:#FFFF1c}.cython.score-82{background-color:#FFFF1b}.cython.score-83{background-color:#FFFF1b}.cython.score-84{background-color:#FFFF1b}.cython.score-85{background-color:#FFFF1a}.cython.score-86{background-color:#FFFF1a}.cython.score-87{background-color:#FFFF1a}.cython.score-88{background-color:#FFFF1a}.cython.score-89{background-color:#FFFF19}.cython.score-90{background-color:#FFFF19}.cython.score-91{background-color:#FFFF19}.cython.score-92{background-color:#FFFF19}.cython.score-93{background-color:#FFFF18}.cython.score-94{background-color:#FFFF18}.cython.score-95{background-color:#FFFF18}.cython.score-96{background-color:#FFFF18}.cython.score-97{background-color:#FFFF17}.cython.score-98{background-color:#FFFF17}.cython.score-99{background-color:#FFFF17}.cython.score-100{background-color:#FFFF17}.cython.score-101{background-color:#FFFF16}.cython.score-102{background-color:#FFFF16}.cython.score-103{background-color:#FFFF16}.cython.score-104{background-color:#FFFF16}.cython.score-105{background-color:#FFFF16}.cython.score-106{background-color:#FFFF15}.cython.score-107{background-color:#FFFF15}.cython.score-108{background-color:#FFFF15}.cython.score-109{background-color:#FFFF15}.cython.score-110{background-color:#FFFF15}.cython.score-111{background-color:#FFFF15}.cython.score-112{background-color:#FFFF14}.cython.score-113{background-color:#FFFF14}.cython.score-114{background-color:#FFFF14}.cython.score-115{background-color:#FFFF14}.cython.score-116{background-color:#FFFF14}.cython.score-117{background-color:#FFFF14}.cython.score-118{background-color:#FFFF13}.cython.score-119{background-color:#FFFF13}.cython.score-120{background-color:#FFFF13}.cython.score-121{background-color:#FFFF13}.cython.score-122{background-color:#FFFF13}.cython.score-123{background-color:#FFFF13}.cython.score-124{background-color:#FFFF13}.cython.score-125{background-color:#FFFF12}.cython.score-126{background-color:#FFFF12}.cython.score-127{background-color:#FFFF12}.cython.score-128{background-color:#FFFF12}.cython.score-129{background-color:#FFFF12}.cython.score-130{background-color:#FFFF12}.cython.score-131{background-color:#FFFF12}.cython.score-132{background-color:#FFFF11}.cython.score-133{background-color:#FFFF11}.cython.score-134{background-color:#FFFF11}.cython.score-135{background-color:#FFFF11}.cython.score-136{background-color:#FFFF11}.cython.score-137{background-color:#FFFF11}.cython.score-138{background-color:#FFFF11}.cython.score-139{background-color:#FFFF11}.cython.score-140{background-color:#FFFF11}.cython.score-141{background-color:#FFFF10}.cython.score-142{background-color:#FFFF10}.cython.score-143{background-color:#FFFF10}.cython.score-144{background-color:#FFFF10}.cython.score-145{background-color:#FFFF10}.cython.score-146{background-color:#FFFF10}.cython.score-147{background-color:#FFFF10}.cython.score-148{background-color:#FFFF10}.cython.score-149{background-color:#FFFF10}.cython.score-150{background-color:#FFFF0f}.cython.score-151{background-color:#FFFF0f}.cython.score-152{background-color:#FFFF0f}.cython.score-153{background-color:#FFFF0f}.cython.score-154{background-color:#FFFF0f}.cython.score-155{background-color:#FFFF0f}.cython.score-156{background-color:#FFFF0f}.cython.score-157{background-color:#FFFF0f}.cython.score-158{background-color:#FFFF0f}.cython.score-159{background-color:#FFFF0f}.cython.score-160{background-color:#FFFF0f}.cython.score-161{background-color:#FFFF0e}.cython.score-162{background-color:#FFFF0e}.cython.score-163{background-color:#FFFF0e}.cython.score-164{background-color:#FFFF0e}.cython.score-165{background-color:#FFFF0e}.cython.score-166{background-color:#FFFF0e}.cython.score-167{background-color:#FFFF0e}.cython.score-168{background-color:#FFFF0e}.cython.score-169{background-color:#FFFF0e}.cython.score-170{background-color:#FFFF0e}.cython.score-171{background-color:#FFFF0e}.cython.score-172{background-color:#FFFF0e}.cython.score-173{background-color:#FFFF0d}.cython.score-174{background-color:#FFFF0d}.cython.score-175{background-color:#FFFF0d}.cython.score-176{background-color:#FFFF0d}.cython.score-177{background-color:#FFFF0d}.cython.score-178{background-color:#FFFF0d}.cython.score-179{background-color:#FFFF0d}.cython.score-180{background-color:#FFFF0d}.cython.score-181{background-color:#FFFF0d}.cython.score-182{background-color:#FFFF0d}.cython.score-183{background-color:#FFFF0d}.cython.score-184{background-color:#FFFF0d}.cython.score-185{background-color:#FFFF0d}.cython.score-186{background-color:#FFFF0d}.cython.score-187{background-color:#FFFF0c}.cython.score-188{background-color:#FFFF0c}.cython.score-189{background-color:#FFFF0c}.cython.score-190{background-color:#FFFF0c}.cython.score-191{background-color:#FFFF0c}.cython.score-192{background-color:#FFFF0c}.cython.score-193{background-color:#FFFF0c}.cython.score-194{background-color:#FFFF0c}.cython.score-195{background-color:#FFFF0c}.cython.score-196{background-color:#FFFF0c}.cython.score-197{background-color:#FFFF0c}.cython.score-198{background-color:#FFFF0c}.cython.score-199{background-color:#FFFF0c}.cython.score-200{background-color:#FFFF0c}.cython.score-201{background-color:#FFFF0c}.cython.score-202{background-color:#FFFF0c}.cython.score-203{background-color:#FFFF0b}.cython.score-204{background-color:#FFFF0b}.cython.score-205{background-color:#FFFF0b}.cython.score-206{background-color:#FFFF0b}.cython.score-207{background-color:#FFFF0b}.cython.score-208{background-color:#FFFF0b}.cython.score-209{background-color:#FFFF0b}.cython.score-210{background-color:#FFFF0b}.cython.score-211{background-color:#FFFF0b}.cython.score-212{background-color:#FFFF0b}.cython.score-213{background-color:#FFFF0b}.cython.score-214{background-color:#FFFF0b}.cython.score-215{background-color:#FFFF0b}.cython.score-216{background-color:#FFFF0b}.cython.score-217{background-color:#FFFF0b}.cython.score-218{background-color:#FFFF0b}.cython.score-219{background-color:#FFFF0b}.cython.score-220{background-color:#FFFF0b}.cython.score-221{background-color:#FFFF0b}.cython.score-222{background-color:#FFFF0a}.cython.score-223{background-color:#FFFF0a}.cython.score-224{background-color:#FFFF0a}.cython.score-225{background-color:#FFFF0a}.cython.score-226{background-color:#FFFF0a}.cython.score-227{background-color:#FFFF0a}.cython.score-228{background-color:#FFFF0a}.cython.score-229{background-color:#FFFF0a}.cython.score-230{background-color:#FFFF0a}.cython.score-231{background-color:#FFFF0a}.cython.score-232{background-color:#FFFF0a}.cython.score-233{background-color:#FFFF0a}.cython.score-234{background-color:#FFFF0a}.cython.score-235{background-color:#FFFF0a}.cython.score-236{background-color:#FFFF0a}.cython.score-237{background-color:#FFFF0a}.cython.score-238{background-color:#FFFF0a}.cython.score-239{background-color:#FFFF0a}.cython.score-240{background-color:#FFFF0a}.cython.score-241{background-color:#FFFF0a}.cython.score-242{background-color:#FFFF0a}.cython.score-243{background-color:#FFFF0a}.cython.score-244{background-color:#FFFF0a}.cython.score-245{background-color:#FFFF0a}.cython.score-246{background-color:#FFFF09}.cython.score-247{background-color:#FFFF09}.cython.score-248{background-color:#FFFF09}.cython.score-249{background-color:#FFFF09}.cython.score-250{background-color:#FFFF09}.cython.score-251{background-color:#FFFF09}.cython.score-252{background-color:#FFFF09}.cython.score-253{background-color:#FFFF09}.cython.score-254{background-color:#FFFF09}pre{line-height:125%}td.linenos .normal{color:inherit;background-color:transparent;padding-left:5px;padding-right:5px}span.linenos{color:inherit;background-color:transparent;padding-left:5px;padding-right:5px}td.linenos .special{color:#000000;background-color:#ffffc0;padding-left:5px;padding-right:5px}span.linenos.special{color:#000000;background-color:#ffffc0;padding-left:5px;padding-right:5px}.cython .hll{background-color:#ffffcc}.cython{background:#f8f8f8}.cython .c{color:#408080;font-style:italic}.cython .err{border:1px solid #FF0000}.cython .k{color:#008000;font-weight:bold}.cython .o{color:#666666}.cython .ch{color:#408080;font-style:italic}.cython .cm{color:#408080;font-style:italic}.cython .cp{color:#BC7A00}.cython .cpf{color:#408080;font-style:italic}.cython .c1{color:#408080;font-style:italic}.cython .cs{color:#408080;font-style:italic}.cython .gd{color:#A00000}.cython .ge{font-style:italic}.cython .gr{color:#FF0000}.cython .gh{color:#000080;font-weight:bold}.cython .gi{color:#00A000}.cython .go{color:#888888}.cython .gp{color:#000080;font-weight:bold}.cython .gs{font-weight:bold}.cython .gu{color:#800080;font-weight:bold}.cython .gt{color:#0044DD}.cython .kc{color:#008000;font-weight:bold}.cython .kd{color:#008000;font-weight:bold}.cython .kn{color:#008000;font-weight:bold}.cython .kp{color:#008000}.cython .kr{color:#008000;font-weight:bold}.cython .kt{color:#B00040}.cython .m{color:#666666}.cython .s{color:#BA2121}.cython .na{color:#7D9029}.cython .nb{color:#008000}.cython .nc{color:#0000FF;font-weight:bold}.cython .no{color:#880000}.cython .nd{color:#AA22FF}.cython .ni{color:#999999;font-weight:bold}.cython .ne{color:#D2413A;font-weight:bold}.cython .nf{color:#0000FF}.cython .nl{color:#A0A000}.cython .nn{color:#0000FF;font-weight:bold}.cython .nt{color:#008000;font-weight:bold}.cython .nv{color:#19177C}.cython .ow{color:#AA22FF;font-weight:bold}.cython .w{color:#bbbbbb}.cython .mb{color:#666666}.cython .mf{color:#666666}.cython .mh{color:#666666}.cython .mi{color:#666666}.cython .mo{color:#666666}.cython .sa{color:#BA2121}.cython .sb{color:#BA2121}.cython .sc{color:#BA2121}.cython .dl{color:#BA2121}.cython .sd{color:#BA2121;font-style:italic}.cython .s2{color:#BA2121}.cython .se{color:#BB6622;font-weight:bold}.cython .sh{color:#BA2121}.cython .si{color:#BB6688;font-weight:bold}.cython .sx{color:#008000}.cython .sr{color:#BB6688}.cython .s1{color:#BA2121}.cython .ss{color:#19177C}.cython .bp{color:#008000}.cython .fm{color:#0000FF}.cython .vc{color:#19177C}.cython .vg{color:#19177C}.cython .vi{color:#19177C}.cython .vm{color:#19177C}.cython .il{color:#666666}

Generated by Cython 0.29.24

Yellow lines hint at Python interaction.
Click on a line that starts with a "`+`" to see the C code that Cython generated for it.

01:
02: ctypedef unsigned long long u64
03:
+04: cpdef u64 splitmix64(u64 x):
static PyObject *__pyx_pw_46_cython_magic_1df062dd335dea8b17c4f61033efc66b_1splitmix64(PyObject *__pyx_self, PyObject *__pyx_arg_x); /*proto*/
static __pyx_t_46_cython_magic_1df062dd335dea8b17c4f61033efc66b_u64 __pyx_f_46_cython_magic_1df062dd335dea8b17c4f61033efc66b_splitmix64(__pyx_t_46_cython_magic_1df062dd335dea8b17c4f61033efc66b_u64 __pyx_v_x, CYTHON_UNUSED int __pyx_skip_dispatch) {
__pyx_t_46_cython_magic_1df062dd335dea8b17c4f61033efc66b_u64 __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("splitmix64", 0);
/* … */
/* function exit code */
__pyx_L0:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_46_cython_magic_1df062dd335dea8b17c4f61033efc66b_1splitmix64(PyObject *__pyx_self, PyObject *__pyx_arg_x); /*proto*/
static PyObject *__pyx_pw_46_cython_magic_1df062dd335dea8b17c4f61033efc66b_1splitmix64(PyObject *__pyx_self, PyObject *__pyx_arg_x) {
__pyx_t_46_cython_magic_1df062dd335dea8b17c4f61033efc66b_u64 __pyx_v_x;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("splitmix64 (wrapper)", 0);
assert(__pyx_arg_x); {
__pyx_v_x = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(__pyx_arg_x); if (unlikely((__pyx_v_x == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 4, __pyx_L3_error)
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
__Pyx_AddTraceback("_cython_magic_1df062dd335dea8b17c4f61033efc66b.splitmix64", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_46_cython_magic_1df062dd335dea8b17c4f61033efc66b_splitmix64(__pyx_self, ((__pyx_t_46_cython_magic_1df062dd335dea8b17c4f61033efc66b_u64)__pyx_v_x));
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;

/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}

static PyObject *__pyx_pf_46_cython_magic_1df062dd335dea8b17c4f61033efc66b_splitmix64(CYTHON_UNUSED PyObject *__pyx_self, __pyx_t_46_cython_magic_1df062dd335dea8b17c4f61033efc66b_u64 __pyx_v_x) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("splitmix64", 0);
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyInt_From_unsigned_PY_LONG_LONG(__pyx_f_46_cython_magic_1df062dd335dea8b17c4f61033efc66b_splitmix64(__pyx_v_x, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;

/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("_cython_magic_1df062dd335dea8b17c4f61033efc66b.splitmix64", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}

+05:     x ^= x >> 30
__pyx_v_x = (__pyx_v_x ^ (__pyx_v_x >> 30));

+06:     x *= <u64>0xbf58476d1ce4e5b9
__pyx_v_x = (__pyx_v_x * ((__pyx_t_46_cython_magic_1df062dd335dea8b17c4f61033efc66b_u64)0xbf58476d1ce4e5b9));

+07:     x ^= x >> 27
__pyx_v_x = (__pyx_v_x ^ (__pyx_v_x >> 27));

+08:     x *= <u64>0x94d049bb133111eb
__pyx_v_x = (__pyx_v_x * ((__pyx_t_46_cython_magic_1df062dd335dea8b17c4f61033efc66b_u64)0x94d049bb133111eb));

+09:     x ^= x >> 31
__pyx_v_x = (__pyx_v_x ^ (__pyx_v_x >> 31));

+10:     return x
__pyx_r = __pyx_v_x;
goto __pyx_L0;

```
In [13]:
`plot_hash(splitmix64)`
Out:

## Prospector

https://nullprogram.com/blog/2018/07/31/

In [14]:
```%%cython

ctypedef unsigned long u32

cpdef u32 prospector32(u32 x):
x ^= x >> 15
x *= <u32>0x2c1b3c6d
x ^= x >> 12
x *= <u32>0x297a2d39
x ^= x >> 15
return x```
In [15]:
`plot_hash(prospector32, bits=32)`
Out:
In [16]:
```%%cython

ctypedef unsigned long u32

cpdef u32 triple32(u32 x):
x ^= x >> 17
x *= <u32>0xed5ad4bb
x ^= x >> 11
x *= <u32>0xac4c1b51
x ^= x >> 15
x *= <u32>0x31848bab
x ^= x >> 14
return x```
In [17]:
`plot_hash(triple32, bits=32)`
Out:

## ARX - Add, Rotate, XOR

This hash is based on ARX, which is usually cheap to execute in software. One advantage is that there are no multiplications. In exchange for having cheaper operations, we have to execute more of them.

In [18]:
```%%cython

ctypedef unsigned char u8
ctypedef unsigned long u32

cdef u32 rotl32(u32 n, u8 k):
cdef u32 a = n << k
cdef u32 b = n >> (32 - k)
return a | b

cpdef u32 arx32(u32 a):
cdef u32 b = 0
cdef u32 c = 0
cdef u32 d = 0

for _ in range(3):
b ^= rotl32(a + d, 7)
c ^= rotl32(b + a, 9)
d ^= rotl32(c + b, 13)
a ^= rotl32(d + c, 18)

return a ^ c```
In [19]:
`plot_hash(arx32, bits=32)`
Out:
In [20]:
```%%cython

ctypedef unsigned char u8
ctypedef unsigned long long u64

cdef u64 rotl64(u64 n, u8 k):
cdef u64 a = n << k
cdef u64 b = n >> (64 - k)
return a | b

cpdef u64 arx64(u64 a):
cdef u64 b = 0
cdef u64 c = 0

for _ in range(4):
b ^= rotl64(a + c, 7)
c ^= rotl64(b + a, 9)
a ^= rotl64(c + b, 13)

return a```
In [21]:
`plot_hash(arx64)`
Out: