crypto_hash_1.py 397 B

12345678910111213
  1. def crypto_hash(message):
  2. """
  3. Hashes and returns the message ``message``.
  4. :param message: bytes
  5. :rtype: bytes
  6. """
  7. digest = ffi.new("unsigned char[]", crypto_hash_BYTES)
  8. rc = lib.crypto_hash(digest, message, len(message))
  9. ensure(rc == 0,
  10. 'Unexpected library error',
  11. raising=exc.RuntimeError)
  12. return ffi.buffer(digest, crypto_hash_BYTES)[:]