Hashing Algorithms, The Brain of Blockchain(SHA-256, SHA-512 and more)

Throughout history, we have seen many new innovations. As time has gone by we have made more complex and intricate discoveries. Without a doubt, blockchain has been one of the most influential and pragmatic innovations of the 21st century.

Some people have been lucky enough to have seen the influence that blockchain has had in the past few years and the impact it will have in the future. Seeing this revolutionary concept unfold and become a reality has truly been a thrilling experience.

Even though there is so much to learn in blockchain, there is one thing people should learn first. I would go far enough to say that without this one thing, blockchain would not be what it is today. The name of this concept is known as a Hashing Algorithm.

What is Blockchain

Taking a step back, it is crucial to have a full understanding of blockchain before we go into what a specific part of it is. A blockchain is a decentralized, digital ledger that contains a systematic series of blocks that are connected to each other, hence the chain part of Blockchain.

These blocks contain data with regard to a certain purpose(Customer banking information, Patient details, Manufacture source traceability, secure ID, etc). Each transaction which takes place is stored in the block and added to the blockchain. These blocks contain a list of growing records in the form of a distributed database.

Blockchain maintains the integrity of its data by validating each block with the help of cryptography. Each participant in the specific blockchain validates the block. Data in a blockchain cannot be modified without the approval of the participants. This is known as proof-of-work.

This image depicts how a blockchain would operate using the proof of work system


One thing that blockchain is known for is its ability to be immutable. When people talk about the “immutability” of blockchain, they are referring to the inability to make adjustments to the data after it is recorded and stored. This is very important when dealing with any type of blockchain. Here are four of the many reasons for why a blockchain is immutable.

  1. One way encryption: What makes blockchain unique is the fact that it is one-way encryption on any input. There is virtually no decryption key because it is a unique encryption every time. The encryption is strongly based on the data that someone puts in, meaning that the same data will always generate the same hash result. This is mathematically impossible to reverse-engineer and this is what makes it a one-way function.
  2. Salting: Salting is the act of adding random data as an additional security measure. It is used on top of the one-way encryption. Essentially, it adds more information to whatever the blockchain is about. This essentially randomizes the output. For example, if you have a password and a salt value. The salt value will be added to the password so that it does not make sense and hackers won't understand what it means.
  3. It is decentralized: One of the most exciting aspects of blockchain technology is that it is entirely decentralized, rather than stored in one central place. This removes the need for powerful central authorities who have control over everything. Instead, several individual users have small amounts of power. When it is stored on different computers, the computers are referred to as nodes.
  4. Each block stores the value of the previous one: The original block is known as the genesis block. When another block gets added the previous block holds the hash value of the one in front of it. For example, if we start at the genesis block, it will hold the value of block number two. As soon as tampering starts to happen with a singular block, it completely changes the hash value of that block. Now if a certain block has tampered with that means that the previous block wouldn't recognize the hash. As soon as this happens the entire system shuts down.
This image shows how the blocks are linked to each other and how each block contains the hash value of the previous block. The first block does not have any previous blocks and it is called the Genisis Block.

As you can see immutability is just emphasizing on the fact that blockchain is very secure and well designed.

Hashing Algorithms outside of Blockchain.

One of the best things about Hashing Algorithms is that it can be used in anything security-related. For example, whenever you sign up for an account on Facebook, Instagram or Snapchat the password you enter goes through the Algorithm and comes out as a hash.

So yes, this means that companies don't know your password after it goes through the hashing algorithm. This just shows that if you understand how hashing algorithms work it will help you tremendously if you are looking into hashing algorithms.

This diagram shows that when you input any type of data (passwords, text, etc.) it goes through the hash algorithm/function and comes out as a new value.

Types of Algorithms

There is not just one hashing algorithm that is used everywhere. There are different hashing algorithms such as SHA-256 or SHA-512. SHA means Secure Hashing Algorithm. There is also MD(MD, MD2, MD4, MD5 and MD6) which stands for Message Digest and RIPEMD(RIPEMD, RIPEMD-128, RIPEMD-256 and RIPEMD-160).

These are examples of commonly used hashing algorithms. In the cryptocurrency world, SHA-256 is generally used the most. Facebook and Bitcoin use SHA-256 as their algorithm. The number means how many bits each output is. Let’s take SHA-256. Every single output will be 256 bits.

Hacking a Hashing Algorithm

Obviously, when something that has to do with security comes out, hackers get very excited. Unfortunately for them, it is virtually impossible to hack and take control over a blockchain. There is only one known way to get into a singular block, through brute force.

Well, you might ask, if it takes a couple of days or weeks it would be worth it. The issue with that is it would take much longer than that. There are three different scenarios.

  1. The first situation is you guess it first try. If someone managed to crack a hashing algorithm on their first attempt, that would go down as the luckiest event in history. Let’s take a 128-bit hash algorithm. The probability of cracking the code is 1/2¹²⁸.
  2. The second situation is you get it on the last combination. Even if you had a supercomputer that could try 1 billion combinations a second, it would still take 3.4028237e+29 seconds to complete the process. Even if your life was 100 years long there would still be 3.4028237e+29 seconds left. This should really put things into perspective.
  3. The last scenario is you get it somewhere within the middle. The probability of this happening is 1.7 X 10³⁸. Either way, the chances of any of these happening is very unlikely.

What next?

If we would have told someone from the 19th century that we took a picture of a real black hole, do you think they would believe us? Personally, I wouldn't. The point that is trying to be made is that blockchain is one of the many different things that will be important in the future.

Hashing Algorithms, Immutability and the proof of work system are some of the most important things in the blockchain world. It is what makes all these incredible advancements in blockchain possible. Hashing and immutability are the main reasons blockchain will be widely adopted commercially. Some times we have to remember that some things might seem so complicated, but it is all run by a simple concept.

If you enjoyed reading my article feel free to email me at rishi30.mehta@gmail.com or contact my Linkedin at https://www.linkedin.com/in/rishi-mehta-12b569140/

15 y/o working on ending open defecation in Nigeria + increasing the energy density of batteries.