首页 > 解决方案 > python 使用 concurrent.futures 库进行 SHA256 + salt 加密

问题描述

我有一个加密函数,它不断计算具有恒定盐值和不同 pwd 字段的新派生哈希,该字段是一个字符串。

def EncyptPrimary(salt, pwd):
dkey = hashlib.pbkdf2_hmac('sha256', pwd, salt, 100000, dklen=32)
return str(binascii.b2a_hex(dkey))

我想使用 concurrent.futures 库跨多个 CPU 运行此功能。

executor.map() 的所有文档都混淆了他们如何让它工作。我试过了。

with concurrent.futures.ProcessPoolExecutor() as executor:
    executor.map(EncyptPrimary(salt, pwd))

但它抛出一个错误说,不能使用类型生成器。

标签: pythonconcurrency

解决方案


推荐阅读