# Hash

A **Hash** or also called **hash function** is any **algorithm** that maps data of arbitrary length to data of a fixed length. The values returned by a hash function are called hash values, hash codes, hash sums, checksums or simply hashes. Recent development of internet payment networks and digital money, such as Bitcoin, also uses a form of 'hashing' for checksums, and has brought additional attention to the term.

## Contents

## Hash function Review[edit]

**Hash functions** are primarily used to generate fixed-length output data that acts as a shortened reference to the original data. This is useful when the original data is too cumbersome to use in its entirety.

One practical use is a data structure called a hash table where the data is stored associatively. Searching linearly for a person's name in a list becomes cumbersome as the length of the list increases, but the hashed value can be used to store a reference to the original data and retrieve constant time (barring collisions). Another use is in cryptography, the science of encoding and safeguarding data. It is easy to generate hash values from input data and easy to verify that the data matches the hash, but hard to 'fake' a hash value to hide malicious data. This is the principle behind the PGP algorithm for data validation.

To be considered effective a hash function has to have following properties:

- Computational efficiency - it shouldn't take a long time to compute a hash from a given input.
- Collision resistance - it should be hard to find to distinct inputs that would result in the same hash after the application of the hash function.
- Ability to hide information - it should be hard to derive anything useful about the input from the hash whether it be the whole input data or as simple info about it as whether it is an odd or an even number.
- Random-looking hash - the hash should look like it was a result of several random events, like flipping a coin. There shouldn't be an apparent particular transformation protocol.

## Hash function – Bitcoin[edit]

Bitcoin uses the SHA-256 hash **algorithm** to generate verifiably "random" numbers in a way that requires a predictable amount of CPU effort. Generating a **SHA-256** hash with a value less than the current target solves a block and wins you some coins.

## External links[edit]

- Hash function page on Wikipedia.org