我需要使用scrypt算法,既然已经在使用hashlib,那么我觉得...为什么不尝试一下呢?我已经检查了这篇文章,指出需要OpenSSL 1.1+。同时,根据官方文档的说明:
hashlib.scrypt(password, *, salt, n, r, p, maxmem=0, dklen=64)
...
可用性:需要OpenSSL 1.1+。
版本3.6中新增。
我确保已安装最新版的openssl:
# openssl version
OpenSSL 1.1.1b 26 Feb 2019
我也尝试运行python3.6 和python3 (3.4) ,但两者都无法导入scrypt:
# python3.6
Python 3.6.5 (default, Apr 10 2018, 17:08:37)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from hashlib import pbkdf2_hmac
>>> from hashlib import scrypt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'scrypt'
如您所见,像 pbkdf2_hmac
这样的其他方法可以使用。可能出了什么问题?
另外,hashlib.scrypt(password, *, salt, n, r, p, maxmem=0, dklen=64)
中的 *
是什么意思?