[英]ModuleNotFoundError: No module named 'Crypto'
我安裝了Crypto模塊和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 = 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 install pycrypto
(需要安裝Microsoft Visual C ++ 14.0)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.