February 2019
Intermediate to advanced
450 pages
9h 59m
English
Now, let's hash the serialized data. IPFS uses multihash to hash the data. This means it is not just outputting the hash output, but it also outputs the hash function that it uses, the length of the hash output from that hash function, and the hash output from that hash function.
Let's take a look at an example of the usage of multihash. Suppose the data that we want to hash is b'i love you'. We choose sha256 as a hash function, as follows:
>>> from hashlib import sha256>>> sha256(b'i love you').hexdigest()'1c5863cd55b5a4413fd59f054af57ba3c75c0698b3851d70f99b8de2d5c7338f
Let's check out the length of this hash output:
>>> len('1c5863cd55b5a4413fd59f054af57ba3c75c0698b3851d70f99b8de2d5c7338f')64
Since a number in hexadecimal format ...