Using crypto instead of hashlib, and cleaning a bug in the example detected by Nitin Gupta