You might have heard that blockchain is most secure to store transaction data. No one can alter the information that resides on blockchain. No one can read the identify of the person and information there on blockchain as data is in encrypted form.
You might have seen text similar to below string very often in blockchain, below text is one example of hash.
Let's understand hash functions that we use in blockchain. Hash is one of the most popular and commonly used feature in blockchain so it become essential to understand this concept.
A hash is a function that converts an input of letters and numbers into an encrypted output of a fixed length. Hash functions are keyless, and they provide the data integrity service.
e.g. hash for "hello" string is aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d.
In blockchain, first data is hashed and then stored on blockchain and there are different types of hash algorithms available and every blockchain use it's own algorithm.
Why to use hash in blockchain ?
Hashing drastically increases the security of the data. Anyone who may be trying to decrypt the data by looking at the hash will not be able to work out the length of the encrypted information based on the hash.
In other words we can say, hash functions are one way only, means you can generate a hash from text/file but not generate raw text/file from hash.
Hash function has many features as explained below,
- Impossible to produce the same hash value for differing inputs: There will never be same hash for two different inputs.
- You will get new hash in case of you make any minute change in the input data.
e.g. hash for "hello" is aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d and hash for "Hello" is different which is f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0.
- Fixed length value: you always get fixed length hash value for any given input. The input can be any text, any MB file or any other information.
- Impossible to determine input based on hash value: This is one of the foremost aspects and qualities of hashing and securing data.
As mentioned earlier, different blockchain use their own hashing algorithms, like Bitcoin use SHA-256 hash algorithm and Ethereum use Keccak-256 hash algorithm.