Crypto、PyCrypto、PyCryptodomeCrypto、PyCrypto、
参考网址附上,今天我真的也是很无奈了,想要做一个密码学的作业,需要用到pycrypto的包,但是安装完之后不能正常调用,就找到了PyCryptodome库,是我要找的没错了。
在cmd或者powershell中直接执行
pip install pycryptodome -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
即可完成安装
只有安装好PyCryptodome之后才可正确import AES
import Crypto.Cipher
from os import urandom
from Crypto.Cipher import AES
#1.Generating a secret key
secret_key = urandom(16)
#2.Generating an initialization vector
iv = urandom(16)
#3.Create an AES cipher
obj = AES.new(secret_key,AES.MODE_CBC,iv)
#4.Encrpt the message with AES
message = 'Lorem Ipsum text'.encode('utf8')
print('Original message is: ', message)
encrypted_text = obj.encrypt(message)
print('The encrypted text', encrypted_text)
输出