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.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Passwords and Cryptographic hash function
- Blockchain in Brief
- How Does the Blockchain Work?
- What Are Cryptoasssets in Blockchain
- Blockchain Forks
- Features of Blockchain
- Blockchain vs Bitcoin
- Blockchain to Secure IoT Data
- Implementation of Blockchain in Java
- How does BlockChain support Crowdfunding ?
- Difference Between Bitcoin and Blockchain
- Benefits of Blockchain in Healthcare
- Introduction to Blockchain technology | Set 1
- Important Blockchain terminologies
- Consensus Algorithms in Blockchain
- Blockchain | Smart Contracts
- Difference between Blockchain and a Database
- Proof of Stake (PoS) in Blockchain
- Introduction to Blockchain technology | Set 2
- Basics of the Blockchain and its various applications
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.