正如我在标题中提到的,我正在尝试使用这个简单的代码来运行库密码:
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。
最佳答案
检查以下几点:
检查安装了哪些版本
which python
//use python or python3 as per your needs
检查所有版本的安装位置
where python
//use python or python3 as per your needs
在我的例子中,我有如下两条路径,
/usr/bin/python
/usr/local/bin/python
所以,现在检查 VS Code,
- 命令 + Shipt + P
- 搜索/选择 Python 解释器
- 选择您正在使用的适当版本,如果未列出,请添加相应的路径并选择相同的路径。
这个解决方案对我有用:)
关于python - 尝试运行密码时出现错误 : "module ' hashlib' has no attribute 'scrypt' ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69204547/