Table of Contents

About

This section is a collection of various hash functions for various datatypes to be hashed. The procedure of creating a hash function is usually additive/multiplicative or rotative.

Additive or Multiplicative Hashing

Additive or multiplicative hashing combines data by either performing an addition or multiplication sequentially by the number of elements in the input. The calculation done on an element value is usually in the form of a multiplication by a prime number.

For example, sequentially adding or multiplying each composition of every element of the input with a prime number:

\begin{eqnarray*}
h(m) &=& \sum_{i=0}^{|m|} m_{i} \circ p \\
&or& \\
h(m) &=& \prod_{i=0}^{|m|} m_{i} \circ p
\end{eqnarray*}

Rotative Hashing

Every element in the input is used to construct the hash but values are put through a process of bitwise shifting which is usually a combination of both left and right shifts with the shift amounts being prime numbers. The result of each pass is added to an accumulator which is passed back as the result.

For example, adding or multiplying each composition of the message shifted left by a prime-number and right by a prime number:

\begin{eqnarray*}
h(m) &=& \sum_{i=0}^{|m|} (m_{i} << p) \circ (m_{i} >> q) \\
&or& \\
h(m) &=& \prod_{i=0}^{|m|} (m_{i} << p) \circ (m_{i} >> q)
\end{eqnarray*}

Index