Hashing in Cryptocurrencies
When reading about cryptocurrencies you may have heard the phrase “each block contains a hash of the previous block” or something similar. Let’s have a look at what this actually means.
Firstly let’s have a look at what hashing is and look at some examples.
Bitcoin utilises the SHA-256 hashing algorithm. Other currencies use different algorithms but it doesn’t really matter, the end result is the same.
If you put a set of data through the SHA-256 hashing algorithm you will receive a hash of that data. As an example, if we use the SHA-256 algorithm on the word cat we would end up with the hash:
If someone then changed the word to dog the hash would be:
If you fancy playing around with the hashing algorithm please have a look at this site.
As you can see this is completely different and the change is immediately apparent.
In a blockchain the first piece on information in any block is the hash of the previous block. This means that if any data in the previous block is changed we can immediately see because its hash will no longer be the same as the hash held in the current block and when your blockchain tried to sync with the main network it would be rejected.
Mining is the process through which the hash of a block is found and validated.
Effectively hashing is the “chain” part of the block and it is what links each block together. This hashing gives the blockchain its immutable nature.