Ch5: Something on Hash
Hash is a function that takes an input string of any length and generates a unique output of a fixed length. SHA256 algorithm is used in bitcoin. SHA256 output is a hexadecimal value of 64 characters with a size of 256 bits (or 32 bytes). It's common to hear 'hashing' or 'hash function' from blockchain articles. They're saying the same thing. Hash has nothing to do with social media ‘hashtag’. A hash is not an encryption, because it cannot be decrypted back to the original text. It's a cryptographic one-way function. Below is an example of a hash function. Sometimes, the output is referred to as hashed text, hash sum/value, digital digest or digest.
You can go online to https://emn178.github.io/online-tools/sha256.html where you can type in any text and get a unique SHA256 output of 64 characters.
For example, when I type in ‘Hello!’, I receive:
ce06092fb948d9ffac7d1a376e404b26b7575bcc11ee05a4615fef4fec3a308b
If I change one character and type in ‘Hello.’, I receive:
1589999b0ca6ef8814283026a9f166d51c70a910671c3d44049755f07f2eb910
Notice that changing a single character will generate a different output.
Double hash is often used in Bitcoin, where one input is hash two times. Later, we'll see how hash plays an important role in blockchain.
Remember
· Hash output is always unique.