SHA-2

class pyhacl.hashlib.sha224

Binding for SHA-224, as a haslib.Hash-like interface, or as a oneshot() function.

__init__()

Create a new hash object seeded with data.

Uses Hacl_Hash_SHA2_malloc_224 upon allocation, and Hacl_Hash_SHA2_free_224 upon de-allocation.

block_size = 64
copy()

Create a copy of the current hash object, so the two can be feeded with different data.

digest() bytes

Produce a 28-bytes hash value out of the current state of the hash object.

Uses Hacl_Hash_SHA2_digest_224.

digest_size = 28
hexdigest() str

Shortcut for digest(data).hex().

classmethod hexoneshot(data: bytes) str

Shortcut for oneshot(data).hex().

name = 'sha224'
classmethod oneshot(data: bytes) bytes

Produce a 28-bytes hash value out of the provided data.

Using this function is faster then using update() and then digest() when the entire data is available right away, and that it is not necessary to keep the state machine around once it has been digested.

Binding for Hacl_Hash_SHA2_hash_224.

update(data: bytes) None

Feed the hash object with data.

Uses Hacl_Hash_SHA2_update_224.

class pyhacl.hashlib.sha256

Binding for SHA-256, as a haslib.Hash-like interface, or as a oneshot() function.

__init__()

Create a new hash object seeded with data.

Uses Hacl_Hash_SHA2_malloc_256 upon allocation, and Hacl_Hash_SHA2_free_256 upon de-allocation.

block_size = 64
copy()

Create a copy of the current hash object, so the two can be feeded with different data.

digest() bytes

Produce a 32-bytes hash value out of the current state of the hash object.

Uses Hacl_Hash_SHA2_digest_256.

digest_size = 32
hexdigest() str

Shortcut for digest(data).hex().

classmethod hexoneshot(data: bytes) str

Shortcut for oneshot(data).hex().

name = 'sha256'
classmethod oneshot(data: bytes) bytes

Produce a 32-bytes hash value out of the provided data.

Using this function is faster then using update() and then digest() when the entire data is available right away, and that it is not necessary to keep the state machine around once it has been digested.

Binding for Hacl_Hash_SHA2_hash_256.

update(data: bytes) None

Feed the hash object with data.

Uses Hacl_Hash_SHA2_update_256.

class pyhacl.hashlib.sha384

Binding for SHA-384, as a haslib.Hash-like interface, or as a oneshot() function.

__init__()

Create a new hash object seeded with data.

Uses Hacl_Hash_SHA2_malloc_384 upon allocation, and Hacl_Hash_SHA2_free_384 upon de-allocation.

block_size = 128
copy()

Create a copy of the current hash object, so the two can be feeded with different data.

digest() bytes

Produce a 48-bytes hash value out of the current state of the hash object.

Uses Hacl_Hash_SHA2_digest_384.

digest_size = 48
hexdigest() str

Shortcut for digest(data).hex().

classmethod hexoneshot(data: bytes) str

Shortcut for oneshot(data).hex().

name = 'sha384'
classmethod oneshot(data: bytes) bytes

Produce a 48-bytes hash value out of the provided data.

Using this function is faster then using update() and then digest() when the entire data is available right away, and that it is not necessary to keep the state machine around once it has been digested.

Binding for Hacl_Hash_SHA2_hash_384.

update(data: bytes) None

Feed the hash object with data.

Uses Hacl_Hash_SHA2_update_384.

class pyhacl.hashlib.sha512

Binding for SHA-512, as a haslib.Hash-like interface, or as a oneshot() function.

__init__()

Create a new hash object seeded with data.

Uses Hacl_Hash_SHA2_malloc_512 upon allocation, and Hacl_Hash_SHA2_free_512 upon de-allocation.

block_size = 128
copy()

Create a copy of the current hash object, so the two can be feeded with different data.

digest() bytes

Produce a 64-bytes hash value out of the current state of the hash object.

Uses Hacl_Hash_SHA2_digest_512.

digest_size = 64
hexdigest() str

Shortcut for digest(data).hex().

classmethod hexoneshot(data: bytes) str

Shortcut for oneshot(data).hex().

name = 'sha512'
classmethod oneshot(data: bytes) bytes

Produce a 64-bytes hash value out of the provided data.

Using this function is faster then using update() and then digest() when the entire data is available right away, and that it is not necessary to keep the state machine around once it has been digested.

Binding for Hacl_Hash_SHA2_hash_512.

update(data: bytes) None

Feed the hash object with data.

Uses Hacl_Hash_SHA2_update_512.