The Python ecosystem involves Python in using other languages and rule sets such as:
and so much else.
Lets take a look at another Standard Library module and talk about what it does.
Hash functions are not designed to preserve content. They don't encrypt. They're about associating some unique finger print with any hashable object.
In [ ]:import hashlib m = hashlib.sha256() m.update(b"Nobody inspects") m.update(b" the spammish repetition") m.digest()
In [ ]:result = hashlib.sha256(b"Nobody inspects the spammish repetition").hexdigest() result
In [ ]:print("Digest size", m.digest_size) print("Block size ", m.block_size)
In class, we looked at a passwords database that doesn't save actual passwords, only hashes thereof. Even system administrators with the keys to the database, have no means to force a hash to run backwards to regain the phrase which was behind it. A hash is a one way street.
Check the Python docs and run the above example with sha224 instead. Do you get past this assertion (unit test)?
In [ ]:# Uncomment me to check your result # assert result == 'a4337bc45a8fc544c03f52dc550cd6e1e87021bc896588bd79e901e2'