List of Hash Functions (All Types with Examples)

A hash function is a mathematical function that converts a numerical input value into another compressed numerical value.

The input to the hash function is of arbitrary length but the output is always of fixed length.

To put it simply, a hash function takes a group of characters and maps it to a value of certain length.

That is to say, for any x input value, you will always receive the same y output value whenever the hash function is run.

f(x) = y

This means every input has a determined output.

The hash value represents the original string of characters but is usually smaller than the original.

Hash functions are very useful and are used in almost all information security applications we use today.

For example, hashing is done for indexing and locating items in databases because it is easier to find the shorter hash value than the longer original string.

Hashing is also used in encryption.

A hash function is also called, a hashing algorithm or message digest function.

The value that you get after processing a set of data through a hash function is called a hash value or sometimes is commonly called a message digest.

Note that the input can be any data like numbers, files and other types of files.

The process of transforming a given set of data to a specific hash value is called hashing the data.

The hash value or message digest is always in form of a hexadecimal number.

For example:

md5(“kifanga”) = fd0c1650d6b63df20911c429a9d70817

The resulting value after hashing is much smaller compared to the data that passed through the function. This makes hash functions to act as a kind of compression functions.

One advantage of hash functions over normal ciphers techniques is that they are super fast and the resulting output is smaller too.

Hashes are supposed to be one-way functions and irreversible.

Also, a hash function should not result in the same value for two different pieces of information.

When two different pieces of data result to the same hash value, in that case, a hash collision has occurred and the function is not fit for use.

Here are different types of hashing algorithms and methods in cryptography.

List of hash functions

A list of Keyed cryptographic hash functions

  • VMAC

This is a block cipher that is based on message authentication code (MAC). This algorithm was proposed by Ted Krovertz and Wei Dai in 2007.

  • UMAC

This is also a message authentication code (MAC) that is calculated by choosing a hash function from a class of hash functions according to a random method and applying it to the message.

  • BLAKE2

This is based on Dan Bernstein’s Chacha stream cipher with a slight permutation on the input block. This is a type of cryptographic hash function that goes up to 512 bits and it’s based on the keyed hash function (prefix-MAC).

  • Poly1305-AES

Uses AES block cipher to expand the key. This is a type of cryptographic message code with 128 bits and it’s nonce-based.

  • SipHash

This is a 64 bits pseudorandom function based on non-collision-resistant PRF.

  • One-key MAC

This is constructed from a block cipher. They are of two types (OMAC1 and OMAC2).

  • PMAC

It works by taking a block cipher and creating a good MAC that is reducible insecurity to the underlying block cipher. It is very similar to the OMAC algorithm.

  • MD6

This is a 512 bits cryptographic hash function based on Merkle tree NLFSR.

  • HMAC

Hash-based message authentication code is a type of MAC that uses a cryptographic hash function and a secret key.

A list of unkeyed cryptographic hash functions

  • BLAKE-256

This is a 256 bits hash function based on HAIFA structure.

  • BLAKE-512

This is a 512 bits hash function based on HAIFA structure.

  • BLAKE2s

This is a type of cryptographic hash function that goes up to 256 bits and it’s based on HAIFA structure.

  • BLAKE2b

This is a type of cryptographic hash function that goes up to 512 bits and it’s based on HAIFA structure.

  • ECOH

This is a type of hash that has a range of 224 to 512 bits.

  • FSB

This is a type of hash that has a range of 160 to 512 bits.

  • GOST

This is a 256 bits hash.

  • Grostl

This is a type of hash that goes up to 512 bits.

  • HAS-160

This is a 160 bits hash.

  • HAVAL

This is a type of hash that has a range of 128 to 256 bits.

  • JH

This is a type of hash that has a range of 224 to 512 bits.

  • MD2

This is a 128 bits hash.

  • MD4

This is a 128 bits hash.

  • MD6

This is a type of cryptographic hash function that goes up to 512 bits and it’s based on Merkle tree NLFSR.

  • MD5

This is a 128 bits hash function based on Merkle–Damgård construction.

  • RadioGatún

This is a type of hash that goes up to 1216 bits.

  • RIPEMD

This is a 128 bits hash.

  • RIPEMD-128

This is also a 128 bits hash.

  • RIPEMD-160

This is a 160 bits hash.

  • RIPEMD-320

This is a 320 bits hash.

  • Snefru

This is a type of hash that has a range of 128 to 256 bits.

  • SWIFFT

This is a 512 bits hash.

  • Whirlpool

This is also a 512 bits hash.

  • SHA-1

This is a 160 bits hash function based on Merkle–Damgård construction.

  • SHA-224

This is a 224 bits hash function also based on Merkle–Damgård construction.

  • SHA-256

This is a 256 bits hash function based on Merkle–Damgård construction.

  • SHA-384

This is a 384 bits hash function based on Merkle–Damgård construction.

  • SHA-512

This is a 512 bits hash function based on Merkle–Damgård construction.

  • SHA-3(Keccak)

This is a hash function based on Sponge function and has an arbitrary bits length.

  • Streebog

This is a type of cryptographic hash function that ranges from 256 to 512 bits and it’s based on Merkle–Damgård construction.

  • Tiger

This is a 192 bits hash function based on Merkle–Damgård construction.

  • Skein

This is a cryptographic hash function based on Unique Block Iteration and has an arbitrary bits length.

  • Spectral Hash

This is a 512 bits hash function based on Wide pipe Merkle–Damgård construction.

A list of Cyclic redundancy checks

  • BSD checksum

This is a 16 bits error-detecting code.

  • Checksum

This is a 32 bits error-detecting code.

  • CRC-16

This is also a 16 bits error-detecting code as the name suggests.

  • CRC-32

This is a 32 bits error-detecting code.

  • CRC-32 MPEG-2

This is a 32 bits error-detecting code.

  • CRC-64

This is a 64 bits error-detecting code.

  • SYSV checksum

This is a 16 bits error-detecting code.

A list of Checksums

  • Sum(Unix)

This is a 16 or 32 bits checksum algorithm.

  • Sum8

This is an 8 bits checksum algorithm.

  • Sum16

This is a 16 bits checksum.

  • Sum24

This is a 24 bits checksum algorithm.

  • Sum32

This is a 32 bits checksum algorithm.

  • Fletcher-4

This is a 4 bits checksum.

  • Fletcher-8

This is an 8 bits checksum.

  • Fletcher-16

This is a 16 bits checksum.

  • Fletcher-32

This is a 32 bits checksum.

  • Adler-32

This is a 32 bits checksum algorithm.

  • Xor8

This is an 8 bits checksum.

  • Luhn algorithm

This is a 1 decimal digit checksum algorithm.

  • Verhoeff algorithm

This is also a 1 decimal digit checksum.

  • Damm algorithm

This is a 1 decimal digit error detection algorithm based on Quasigroup operation

A list of Non-cryptographic hash functions

  • Pearson hashing

This is an 8 bits (and more) hash function based on XOR/table.

  • Paul Hsieh’s superFasthash

This is a 32 bits hash function.

  • Buzhash

This is a hash function based on XOR/table and has a variable bits length.

  • Fowler-Noll-Vo hash function(FNV Hash)

This is a non-cryptographic hash function based on xor/product or product/XOR and has (32, 64, 128, 256, 512, or 1024 bits) lengths.

  • Jenkins hash function

This is a non-cryptographic hash function based on XOR/addition and has (32 or 64 bits) lengths.

  • Java hashCode()

This is a 32 bits non-cryptographic hash.

  • Bernstein hash djb2

This is also a 32 bits non-cryptographic hash.

  • PJW hash(ElF Hash)

This is a 32 or 64 bits hash.

  • MurmurHash

This is a non-cryptographic hash function based on product/rotation and has (32, 64, or 128 bits) lengths.

  • Fast-Hash

This is a non-cryptographic hash function based on Xorshift operations and has (32, 64 bits) lengths.

  • SpookyHash

This is a 32, 64, or 128 bits non-cryptographic hash.

  • CityHash

This is a 64, 128, or 256 bits non-cryptographic hash.

  • FarmHash

This is a 32, 64 or 128 bits non-cryptographic hash.

  • MetroHash

This is a 64 or 128 bits non-cryptographic hash.

  • Numeric hash(nhash)

This is a non-cryptographic hash function based on Division/Modulo and has a variable bits length.

  • xxHash

This is a non-cryptographic hash function based on product/rotation and has a 32 or 64 bits length.

  • HighwayHash

This is a non-cryptographic hash function based on product/permutation and has a 64, 128, or 256 bits length.

  • T1ha (Fast Positive Hash)

This is a non-cryptographic hash function based on product/rotation/XOR/add and has a 64 and 128 bits length.

A list of Universal hash function families

  • Zobrist hashing

This is a cryptographic hash function based on XOR and has a variable bits length.

  • Universal one-way hash function

This is a hash function that acts as an alternative to collision-resistant hash functions (CRHFs).

  • Tabulation hashing

This is a hash function based on XOR and has a variable bits length.

  • Rabin fingerprint

This is a hash based on multiple and has a variable bits length.

A list of other hash functions

  • Atelopus

This is a 32 or 64 bits cryptographic hash.

  • Bash

This is a 256, 384 or 512 bits hash.

  • BMW

This is a 256 or 512 bits hash.

  • Cheetah

This is a 256 or 512 bits hash.

  • CubeHash

This is a 81, 82, 84, 88, 161, 162, 164, 168 or 512 bits cryptographic hash.

  • Echo

This is a 256 or 512 bits hash.

  • Echosp hash function

This is a 256 or 512 bits cryptographic hash.

  • Edonr hash function

This is a 256 or 512 bits hash.

  • Essence

This is a 224, 256, 384 or 512 bits hash.

  • Fugue

This is a 2, 256, 384 or 512 bits hash.

  • Hamsi

This is a 256 or 512 bits hash.

  • Lane

This is a 256 or 512 bits hash.

  • Luffa

This is a 256, 384 or 512 bits hash.

  • Lux

This is a 256 or 512 bits hash.

  • Mcssha (4, 5 or 6)

This is a 512 bits hash.

  • Nasha

This is a 256 or 512 bits hash.

  • RFSB-509

This hash uses SHA-256 as an output filter.

  • Round3jh

This is a 256 or 512 bits cryptographic hash.

  • Sarmal

This is a 256 or 512 bits cryptographic hash.

  • Shabal

This is a 256 or 512 bits hash.

  • Shake

This is a 128 or 256 bits cryptographic hash.

  • Shavite (3256, 3512)

This is a 256 or 512 bits hash.

  • Simd

This is a 256 or 512 bits cryptographic hash.

Features of Hash Functions

Here are two features of hash functions

  • Fixed length output (hash value)

Any hash function should be able to convert data of arbitrary length to a fixed length. This process is called hashing of data.

The hash value is often smaller than the input data, thus making hash functions to act as compression functions.

The hash value is a smaller representation of a larger data often called a digest. Most hash functions generate values between 160 and 512 bits.

  • Efficiency of operation

For any hash function when given input x, the computation of the hash value should be very fast. Normally symmetric encryption is much faster than computationally hash functions.

Properties of hash functions

Here are three properties of hash functions

  • Pre-Image Resistance

This simply means that is should be very hard to reverse a hash function.

For example of a hash function k produces a hash value of p, then it should be a difficult process to find any input value y that hashes to p.

The importance of this property is to prevent an attacker who only has a hash value and is trying to find the input.

  • Second Pre-Image Resistance

This means that, given an input and its hash, it should be very hard to find a different input with the same hash.

For example, if a hash function k for an input x produces hash value k(x), then it should be hard to find any other input value y such that k(y) = k(x).

The importance of this property is to protect against an attacker who has an input value and its hash and wants to substitute different value as a legitimate value in place of the original input value.

  • Collision Resistance (collision-free hash function)

This means it should be hard to find two different inputs of any length that result in the same hash.

For example, for a hash function k, it should be hard to find any two different inputs x and y such that k(x) = k(y).

The fact that a hash function is a compressing function with fixed hash length, it is very hard not to have collisions.

The importance of this property is to make it hard for an attacker to find two input values with the same hash.

Design of hashing algorithms

The Merkle–Damgård construction or Merkle–Damgård hash function is the most common method of building collision-resistant cryptographic hash functions from collision-resistant one-way compression functions.

How are cryptographic hash functions used

Here are five applications of hash functions in today’s technology:

  • Hashing is used with a database to enable items to be retrieved more efficiently. Often used for password storage.
  • Hashing is also used in the encryption and decryption of digital signatures.
  • A hash function is used in folding, taking an original value, dividing it into several parts, then adding the parts and using the last four remaining digits as the hashed value or key.
  • It’s also used in digital rearrangement, taking the digits in certain positions of the original value, such as the third and sixth numbers, and reversing their order, then using the number left over as the hashed value.
  • Data integrity check used to generate the checksums on data files. This provides assurance to users about the correctness of the data.

Popular hash functions

Here are five well-known hash functions in use today:

  • Hashed Message Authentication Code (HMAC): Combines authentication via a shared secret with hashing.
  • Message Digest 2 (MD2): Byte-oriented, produces a 128-bit hash value from an arbitrary-length message, designed for smart cards.
  • MD4: Similar to MD2, designed specifically for fast processing in software.
  • MD5: Similar to MD4 but slower because the data is manipulated more. Developed after potential weaknesses were reported in MD4.
  • Secure Hash Algorithm (SHA): Modeled after MD4 and proposed by NIST for the Secure Hash Standard (SHS), produces a 160-bit hash value.

Characteristics of a Good Hash Function

Here are four main characteristics of a good hash function:

  • The hash value should be fully determined by the data being hashed.
  • The hash function should use all the input data.
  • The hash function should uniformly distribute the data across the entire set of possible hash values.
  • The hash function should generate very different hash values for similar strings.

 

Now I want to hear from you.

What do you think of this guide?

Or maybe I missed an important aspect of hash functions.

Either way, let me know by leaving a comment below.

LEAVE A REPLY

Please enter your comment!
Please enter your name here