SHA-384¶
SHA-384 belongs to the SHA-2 family of cryptographic hashes. It produces the 384 bit digest of a message.
SHA-384 is roughly 50% faster than SHA-224 and SHA-256 on 64-bit machines, even if its digest is longer. The speed-up is due to the internal computation being performed with 64-bit words, whereas the other two hash functions employ 32-bit words.
SHA-512, SHA-512/224, and SHA-512/256 too are faster on 64-bit machines for the same reason.
This is an example showing how to use SHA-384:
>>> from Crypto.Hash import SHA384
>>>
>>> h = SHA384.new()
>>> h.update(b'Hello')
>>> print(h.hexdigest())
SHA stands for Secure Hash Algorithm.
SHA-384 is not vulnerable to length-extension attacks.
- class Crypto.Hash.SHA384.SHA384Hash(data=None)¶
A SHA-384 hash object. Do not instantiate directly. Use the
new()
function.- Variables:
oid (string) – ASN.1 Object ID
block_size (integer) – the size in bytes of the internal message block, input to the compression function
digest_size (integer) – the size in bytes of the resulting hash
- copy()¶
Return a copy (“clone”) of the hash object.
The copy will have the same internal state as the original hash object. This can be used to efficiently compute the digests of strings that share a common initial substring.
- Returns:
A hash object of the same type
- digest()¶
Return the binary (non-printable) digest of the message that has been hashed so far.
- Returns:
The hash digest, computed over the data processed so far. Binary form.
- Return type:
byte string
- hexdigest()¶
Return the printable digest of the message that has been hashed so far.
- Returns:
The hash digest, computed over the data processed so far. Hexadecimal encoded.
- Return type:
string
- new(data=None)¶
Create a fresh SHA-384 hash object.
- update(data)¶
Continue hashing of a message by consuming the next chunk of data.
- Parameters:
data (byte string/byte array/memoryview) – The next chunk of the message being hashed.
- Crypto.Hash.SHA384.new(data=None)¶
Create a new hash object.
- Parameters:
data (byte string/byte array/memoryview) – Optional. The very first chunk of the message to hash. It is equivalent to an early call to
SHA384Hash.update()
.- Return:
A
SHA384Hash
hash object