npm install js-sha3):
John Smithis hashed to the hash value
Lisa Smithis hashed to
01. The input texts
Sandra Deeboth are hashed to
02and this is called "collision".
ehllowill have the same hash code. Better hash functions may use the Merkle–Damgård construction scheme, which takes the first byte as state, then transforms the state (e.g. multiplies it by a prime number like 31), then adds the next byte to the state, then again transforms the state and adds the next byte, etc. This significantly reduces the rate of collisions and produces better distribution.
SHA-256and calculate the hash value of certain text message
hello) from its hash value (in the above example
2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824). It is well-known that cryptographic hash functions cannot be reversed back, so they are used widely to encode an input without revealing it (e.g. encode a private key to a blockchain address without revealing the key).
SHA3-512and calculate the hash value of the same text message