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.
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)
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.
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.
- Blockchain vs Bitcoin
- Create simple Blockchain using Python
- Implementation of Blockchain in Java
- Introduction to Blockchain technology | Set 1
- Introduction to Blockchain technology | Set 2
- How Does the Blockchain Work?
- Blockchain | Smart Contracts
- Blockchain Forks
- Important Blockchain terminologies
- Types of Blockchain and Chain Terminology
- Consensus Algorithms in Blockchain
- Blockchain to Secure IoT Data
- Difference between Blockchain and a Database
- What Are Cryptoasssets in Blockchain
- Blockchain in Brief
- Basics of the Blockchain and its various applications
- Proof of Stake (PoS) in Blockchain
- Features of Blockchain
- How does BlockChain support Crowdfunding ?
- Demur-rage currencies in Blockchain
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.