def _openssl_pbkdf2(data, salt, iterations, digest, keylen):
 c_hashfunc = ctypes.c_void_p(_openssl_hashlib_to_crypto_map_get(digest))
 c_pass = ctypes.c_char_p(data)
 c_passlen = ctypes.c_int(len(data))
 c_salt = ctypes.c_char_p(salt)
 c_saltlen = ctypes.c_int(len(salt))
 c_iter = ctypes.c_int(iterations)
 c_keylen = ctypes.c_int(keylen)
 c_buff = ctypes.create_string_buffer(keylen)
 crypto.PKCS5_PBKDF2_HMAC.argtypes = [ctypes.c_char_p, ctypes.c_int, ctypes.c_char_p, ctypes.c_int, ctypes.c_int, ctypes.c_void_p, ctypes.c_int, ctypes.c_char_p]
 crypto.PKCS5_PBKDF2_HMAC.restype = ctypes.c_int
 err = crypto.PKCS5_PBKDF2_HMAC(c_pass, c_passlen, c_salt, c_saltlen, c_iter, c_hashfunc, c_keylen, c_buff)
 return (err, c_buff)

def _openssl_pbkdf2 ( data , salt , iterations , digest , keylen ) : c_hashfunc = ctypes . c_void_p ( _openssl_hashlib_to_crypto_map_get ( digest ) ) c_pass = ctypes . c_char_p ( data ) c_passlen = ctypes . c_int ( len ( data ) ) c_salt = ctypes . c_char_p ( salt ) c_saltlen = ctypes . c_int ( len ( salt ) ) c_iter = ctypes . c_int ( iterations ) c_keylen = ctypes . c_int ( keylen ) c_buff = ctypes . create_string_buffer ( keylen ) crypto . PKCS5_PBKDF2_HMAC . argtypes = [ ctypes . c_char_p , ctypes . c_int , ctypes . c_char_p , ctypes . c_int , ctypes . c_int , ctypes . c_void_p , ctypes . c_int , ctypes . c_char_p ] crypto . PKCS5_PBKDF2_HMAC . restype = ctypes . c_int err = crypto . PKCS5_PBKDF2_HMAC ( c_pass , c_passlen , c_salt , c_saltlen , c_iter , c_hashfunc , c_keylen , c_buff ) return ( err , c_buff )
openssl compatibile wrapper .