正如我在标题中提到的,我试图通过使用以下简单的代码来运行库密码:
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。
2条答案
按热度按时间zwghvu4y1#
您是否尝试构建最新的OpenSSL?我在此处看到说明:https://www.howtoforge.com/tutorial/how-to-install-openssl-from-source-on-linux/(无法尝试此操作,因为我没有运行Linux)。请告诉我们此操作是否有效。
8i9zcol22#
检查已安装的所有版本
该Python
检查所有版本的安装位置
其中Python
在我的例子中,我有两条路,如下所示:
因此,现在检查VS代码,
这个解决方案对我很有效:)