Registry / security / hkdf
library0.0.3pypypi✓ verified 84d ago

Python implementation of HMAC-based Extract-and-Expand Key Derivation Function (HKDF) as defined in RFC 5869. Current version 0.0.3. Low-maintenance, no recent releases.

pip install hkdf
INSTALL
IMPORT
SIG · HKDF
H
hkdf
securitypythonv0.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Hkdf
from hkdf import Hkdf
from hkdf import HKDF
The class is named Hkdf (capital H, lowercase kdf), not HKDF.
expand_key
from hkdf import Hkdf hkdf = Hkdf(salt, ikm) key = hkdf.expand_key(info, length)
hkdf = Hkdf(salt, ikm) key = hkdf.expand(info, length)
The method is expand_key, not expand.

Derive a 32-byte key using HKDF with random salt and input key material.

from hkdf import Hkdf import os ikm = os.urandom(32) salt = os.urandom(16) info = b'myapp key' hkdf = Hkdf(salt, ikm) key = hkdf.expand_key(info, 32) print(key.hex())
Debug
Known issues
deprecatedThe library is not actively maintained; consider using cryptography.hazmat.primitives.kdf.hkdf.HKDF instead.
fix
Use the cryptography library's HKDF implementation for better security and maintenance.
affects: >=0.0.3
gotchaThe class name is Hkdf (not HKDF) and the method is expand_key (not expand).
fix
Use from hkdf import Hkdf and call hkdf.expand_key(info, length).
affects: >=0.0.3
Errors
Common errors & fixes
ImportError: cannot import name 'HKDF' from 'hkdf'
Using wrong case for class name; correct is Hkdf.
fix
Use from hkdf import Hkdf.
AttributeError: 'Hkdf' object has no attribute 'expand'
Using wrong method name; correct is expand_key.
fix
Use hkdf.expand_key(info, length) instead of hkdf.expand(info, length).
Upgrade
Version history
0.0.3latest on PyPI · released Jun 16, 2015
Audit
Dependencies

No dependency data recorded yet.

Agent activity
31 hits · last 30 days
node
28
OpenAI (training)
1
Resources