Pbkdf2

cometa.cryptography.pbkdf2.pbkdf2_hmac_sha512(password, salt, iterations, key_length)[source]

Derives a key using PBKDF2 with HMAC-SHA512.

PBKDF2 (Password-Based Key Derivation Function 2) applies a pseudorandom function to the password along with a salt value, repeating the process multiple times to produce a derived key.

Parameters:
  • password (bytes | bytearray | str) – The input password or passphrase.

  • salt (bytes | bytearray) – A cryptographic salt value.

  • iterations (int) – Number of iterations (higher = more secure but slower).

  • key_length (int) – Desired length of the derived key in bytes.

Returns:

The derived key as bytes.

Raises:

CardanoError – If key derivation fails.

Return type:

bytes

Example

>>> key = pbkdf2_hmac_sha512(b"password", b"salt", 10000, 32)
>>> len(key)
32