Last active
October 12, 2016 10:13
-
-
Save brake/18ab6f269fdef090034d1805308422c6 to your computer and use it in GitHub Desktop.
Example Key Derivation Function based on Pycrypto module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from binascii import unhexlify | |
from functools import partial | |
from Crypto.Protocol import KDF | |
from Crypto.Hash import SHA512, HMAC | |
_SALT = unhexlify('48B755AB80CD1C3DA61182D3DCD2E3A2CA869B783618FF6551FB4B0CDC3B8066') # some salt | |
_KEY_LENGTH = 32 | |
key_derivation_fn = partial( | |
KDF.PBKDF2, | |
salt=_SALT, | |
dkLen=_KEY_LENGTH, | |
count=5000, | |
prf=lambda p,s: HMAC.new(p,s,SHA512).digest() | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment