Blockchain is a constantly growing ledger that keeps a permanent record of all the transactions that have taken place, in a secure, chronological and immutable way. To make the data secure blockchain uses hash function.

**Hashing:**

In simple terms, hashing means taking an input string of any length and giving out an output of a fixed length. The fixed-length output is called an equivalent hash or simply hash.

**Types of cryptographic hash functions:**

- Secure Hashing Algorithm (SHA-2 and SHA-3)
- RACE Integrity Primitives Evaluation Message Digest (RIPEMD)
- Message Digest Algorithm 5 (MD5)
- BLAKE2

**SHA-256:**

SHA-256 is the most famous of all cryptographic hash functions because it’s used extensively in blockchain technology. SHA-256 Hashing algorithm was developed by the National Security Agency (NSA) in 2001.

**Hashing process:**

For this hash function we can use Anders Brownworth Hash Program, a program developed by Anders Brownworth.

If we type any character in the data section, we will observe its corresponding cryptographic hash in the hash section.

**Small Changes In The Input Changes the Hash:**

If we make a small change in the input, the equivalent hash produced will be entirely different.

Changing the capital “T” to small “t” completely changed the equivalent hash.

It is very difficult to determine the original string from the equivalent hash but its not impossible. The only method to determine the original string from its hash is by using “brute-force”. Brute-force basically means that we have to take random inputs, hash them and compare them with the target hash.

There can be basically three scenarios:

**Best case scenario:**

We get our answer on the first try. The odds of this happening are astronomical.**Average case scenario:**

In case of SHA-256 we get our answer after 2^256/2 = 2^255 times. In other words, its a huge number.**Worst case scenario:**

We get our answer at the end of data.

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the **CS Theory Course** at a student-friendly price and become industry ready.