[Python] PBKDF2() got an unexpected keyword argument 'hmac_hash_module'

Discussão em 'Python' iniciado por Stack, Abril 6, 2025.

  1. Stack

    Stack Membro Participativo

    I am attempting to derive AES keys using PBKDF2 from PyCryptoDome using the example code from PyCryptoDome documentation, shown below:

    from Crypto.Protocol.KDF import PBKDF2
    from Crypto.Hash import SHA512
    from Crypto.Random import get_random_bytes

    password = b'my super secret'
    salt = get_random_bytes(16)
    keys = PBKDF2(password, salt, 64, count=1000000, hmac_hash_module=SHA512)
    key1 = keys[:32]
    key2 = keys[32:]


    When I run this, I get the error:

    keys = PBKDF2(password, salt, 64, count=1000, hmac_hash_module="SHA512")
    TypeError: PBKDF2() got an unexpected keyword argument 'hmac_hash_module'


    But when I run the code without the hmac_hash_module argument, it runs without error. Does anyone know why I can't specify this argument?

    Continue reading...

Compartilhe esta Página