Let us see today when and why do we use abi.encode
vs abi.encodePacked
.
What is a hash function?
A hash function has the following characterisitics:
- A function that takes in arbitrary size input and outputs a data of fixed size
- Properties:
- Deterministic
- hash(x) = h, every time without fail
- quick to compute the hash
- irreversible
- given h, (really)hard to find x such that hash(x) = h
- small change in input changes the output significantly
- hard to find x, y such that hash(x) = hash(y)
- Deterministic