This section will explain the steps that have been provided in the previous section:
- In step 1, we import hashlib, a standard Python library for hash computation. We also specify the file we will be hashing—in this case, the file is python-3.7.2-amd64.exe.
- In step 2, we instantiate an md5 object and an sha256 object and specify the size of the chunks we will be reading.
- In step 3, we utilize the .update(data) method. This method allows us to compute the hash incrementally because it computes the hash of the concatenation. In other words, hash.update(a) followed by hash.update(b) is equivalent to hash.update(a+b).
- In step 4, we print out the hashes in hexadecimal digits.
We can also verify that our computation is consistent ...