## What is a hash function?

A hash function takes an arbitrary string as input then it produces an output that is **fixed in length** called **Message Digest** or **Hash Value** or just **Hash**.

So, SHA-256 is a hash function that always produces 256 bit long output.

## What is SHA?

SHA stands for “**Secure Hash Algorithm**” is an algorithm to produce hash output from an input.

Its enhanced version is called **SHA-1**. The algorithm offers five separate hash functions which were created by **National Security Agency** (NSA) and were issued by the **National Institute of Standards and Technology** (NIST).

## MD4, MD5, SHA-256, SHA-512

An **n-bit hash** is a map from arbitrary length messages to **n-bit hash values**.

Current popular hashes produce hash values of length n = 128 (MD4 and MD5) and n = 160 (SHA-1)

An **n- bit cryptographic hash** is an n-bit hash which is **one-way and col lision-resistant**. Therefore above hashes can provide no more than 64 or 80 bits of security, respectively, against collision attacks.

SHA-256 is a 256-bit hash and is meant to provide 128 bits of security against collision attacks.

SHA-512 is a 512-bit hash, and is meant to provide 256 bits of security against collision attacks.