def test_hash(): msg = b"message" h1 = c.crypto_hash(msg) assert len(h1) == c.crypto_hash_BYTES assert tohex(h1) == ("f8daf57a3347cc4d6b9d575b31fe6077" "e2cb487f60a96233c08cb479dbf31538" "cc915ec6d48bdbaa96ddc1a16db4f4f9" "6f37276cfcb3510b8246241770d5952c") assert tohex(h1) == hashlib.sha512(msg).hexdigest() h2 = c.crypto_hash_sha512(msg) assert len(h2) == c.crypto_hash_sha512_BYTES assert tohex(h2) == tohex(h1) h3 = c.crypto_hash_sha256(msg) assert len(h3) == c.crypto_hash_sha256_BYTES assert tohex(h3) == ("ab530a13e45914982b79f9b7e3fba994" "cfd1f3fb22f71cea1afbf02b460c6d1d") assert tohex(h3) == hashlib.sha256(msg).hexdigest()