Python ModuleNotFoundError:没有名为';加密';
我安装了加密模块和SHA256,但显示ModuleNotFoundError :- 回溯(最后一次调用):文件“Digitalsig.py”,第1行,在 从Crypto.Hash导入SHA256 ModuleNotFoundError:没有名为“Crypto”的模块 这是参考代码Python ModuleNotFoundError:没有名为';加密';,python,cryptography,sha256,pycrypto,rsa-sha256,Python,Cryptography,Sha256,Pycrypto,Rsa Sha256,我安装了加密模块和SHA256,但显示ModuleNotFoundError :- 回溯(最后一次调用):文件“Digitalsig.py”,第1行,在 从Crypto.Hash导入SHA256 ModuleNotFoundError:没有名为“Crypto”的模块 这是参考代码 from Crypto.Hash import SHA256 from Crypto.PublicKey import RSA from Crypto import Random random_generator =
from Crypto.Hash import SHA256
from Crypto.PublicKey import RSA
from Crypto import Random
random_generator = Random.new().read
#used to generate a keypair which contain a public and private key
keyPair = RSA.generate(1024,random_generator)
pubKey = keyPair.publicKey()
plainText = 'Hello World'
hashA = SHA256.new(plainText).digest()
digitalSignature = keyPair.sign(hashA,'')
print("Hash A: "+repr(hashA) + "\n");
print("Digital Signature: " + repr(digitalSignature) + "\n")
#Bob receives the plainText and digitalSignature from Alice
#plainTextChanged ='Hello World'
hashB =SHA256.new(plainText).digest()
print("Hash B: " + repr(hashB) + "\n")
if(pubKey.verify(hashB, digitalSignature)):
print("Match")
else:
print("No Match")
首先使用pip安装一个模块
pip安装pycrypto
(需要安装微软Visual C++ 14)您是否检查模块是否已安装?它是否安装在正确的环境中(例如Python2/Python3)?是的,我已经看到..它安装在正确的环境中使用
pycryptodome
,这是一个较新的、不易受攻击的、官方的和受支持的版本<代码>pip安装pycryptodome