A
hash function is any
function that can be used to map
data of arbitrary size to data of fixed size. The values returned by a hash function are called
hash values,
hash codes,
hash sums, or simply
hashes. One use is a data structure called a
hash table, widely used in computer software for rapid data lookup. Hash functions accelerate table or database lookup by detecting duplicated records in a large file. An example is finding similar stretches in DNA sequences. They are also useful in
cryptography. A
cryptographic hash function allows one to easily verify that some input data maps to a given hash value, but if the input data is unknown, it is deliberately difficult to reconstruct it (or equivalent alternatives) by knowing the stored hash value. This is used for assuring
integrity of transmitted data, and is the building block for
HMACs, which provide
message authentication.