What is Hashing ? — How it’s used in Blockchain

Aryan Singh
3 min readSep 2, 2022

--

Hashing is a function that takes arbitrary length of data as input & returns a value of fixed size, the output is called a hash.

  • The size of the hash depends on the algorithm used. Some Common Hashing Algorithms are MD5 (Message Digest — 128 bit), SHA-1 (168 Bits) & SHA-2 Hashing Family have 224, 256, 384 or 512 bit size.
  • Bitcoin uses the SHA-256 algorithm where SHA stands for secure Hashing Algorithm and 256 is the bit size of the hash. A SHA256 hash is a hexadecimal value containing 64 characters (0–9,A-R).
  • Hashing is a one way function that means the original data cannot be retrieved from a hash unlike cryptography where it is possible to decrypt the key to get the original message. So one should not confuse hashing with cryptography
  • A hash function always returns a unique hash value for every data, hash is a unique identity like we have our fingerprint. As two people can never have the same fingerprint so does 2 files can never have same hashes, if this happens it’s called collision. And the function that generates two similar hashes for two different data, the function becomes obsolete. Message Digest (MD4 & MD5) are no longer used because of collision. The current industry dominant hashing algorithm is SHA2 family.

Hashing in Blockchain

Transaction Hash

Each transaction in a blockchain is identified by a hash. This hash is like a fingerprint for the transaction. You can look into the details of a transaction, just by searching it’s hash on a blockchain explorer.

Block Hash

As we know the transactions are stored in blocks in a form of hash, the block is itself identified by a hash. And the block is valid when the hash is validated by a miner using Nonce.

Blockchain

When a block is created, it is linked to the blockchain using the hash of the preceding block, you can imagine it like a linked list. The first block in a blockchain is called the genesis block, the bitcoin genesis block was mined on Jan 3, 2009.

You can demonstrate blockchain hashing here

Find awesomeness here:

📌 youtube.com/0xblocktrain

📌 instagram.com/0xblocktrain

📌 twitter.com/0xblocktrain

--

--