January 2019
Beginner to intermediate
372 pages
11h 17m
English
The following example script uses the SHA-256 hashing algorithm to compute a digest of the message:
from Crypto.Hash import SHA256 hash_object = SHA256.new(data=b'First') print(hash_object.hexdigest()) hash_object.update(b'd') print(hash_object.hexdigest())
Let's consider the output of the preceding script and make a few observations:
a151ceb1711aad529a7704248f03333990022ebbfa07a7f04c004d70c167919f 18902d9ed3b47effdb6faf90ea69b2ef08ef3d25c60a13454ccaef7e60d1cfe1
As we can see, both the hash values in the output have 64 hexadecimal digits (256 bits) irrespective of the size of the message. The first hash value has a message "First," and the second one has "Firstd" (the update function appends the ...
Read now
Unlock full access