【发布时间】:2021-09-16 08:02:33
【问题描述】:
正如我在标题中提到的,我正在尝试使用这个简单的代码来运行库密码:
import cryptocode
password = "This is a test"
key = "My Key"
def encrypt(password, key):
return cryptocode.encrypt(password, key)
def decrypt(encryptetpass):
return cryptocode.decrypt(encryptetpass, key)
encrypted_pass = encrypt(password, key)
print(encrypted_pass)
print(decrypt(encrypted_pass))
在 Windows 上本地运行时,我没有收到任何错误,但在 Linux 上尝试相同的操作会产生标题中提到的错误:
(venv) pwd$ python3.9 crypt_test.py
Traceback (most recent call last):
File "/crypt_test.py", line 15, in <module>
encrypted_pass = encrypt(password, key)
File "/crypt_test.py", line 8, in encrypt
return cryptocode.encrypt(password, key)
File "/venv/lib/python3.9/site-packages/cryptocode/myfunctions.py", line 16, in encrypt
private_key = hashlib.scrypt(
AttributeError: module 'hashlib' has no attribute 'scrypt'
我尝试更新 Openssl,重新安装了我的 venv 和 Python。
【问题讨论】:
-
请发布您与minimal reproducible example 相处的产生错误的完整回溯
-
另外,你用的是什么版本的python?是否有可能在 Linux 上使用 3.6 甚至 python2 之前的 python 版本?
-
@buran,我做了编辑。如您所见,我使用的是 Python3.9。
-
hashlib.scrypt注意到它需要 OpenSSL 1.1+,听起来你的 Python 的 Linux 版本是使用其他版本的 OpenSSL 构建的
标签: python cryptography hashlib