Disclaimer:
Consensus algorithm is the magic behind our current decentralized technologies and blockchain. Let’s explain by comparing with the traditional financial markets centralized by big banks and organizations. When removing these middlemen, the market basically says a majority of participants will participate in validating a transaction. Thanks to blockchain, every participants will have the same log of all transactions on the blockchain. The mechanism works by comparing the hashes of these transactions with each other. If match, the transaction is successful.
To further explain this, it is necessary to understand why transactions on blockchain are difficult to hack and tampered with. A block can contains about 100 transactions. In the process of mining, more blocks will be added to the blockchain. Each transaction and block then have their unique hash (a digital signature) when an action i.e transaction is performed successfully. These hash values are calculated not only based on the current transactions but also the previous blocks. You can’t hack one block without messing with all the blockchain. Of course, a blockchain always have a genesis block that is hardcoded as the base block for all others.
Another term for this mechanism is Proof of Work. All participants will participate in guessing the value of the block. If guessed successfully, the miner is rewarded with the cryptocurrency. Proof of Work is used by all big cryptocurrencies like bitcoin and euthereum, bitcoin cash..