Environmental pyhton3.6
Pip is upgraded to more than 10.0, or it may not be possible to install.
Bo Master in order to decode AES for 1 days, Ann a variety of bags, but walked a lot of pits, here to provide you with a simple method
First on the command line (recommended) pip install Crypto
You will find that the package name installed is lowercase. (crypto)
The path to the package is under your python/lib/site_packages.
You must first change to uppercase (Crypto)
However, importing from Crypto.cipher import AES is an error because you also need to install dependent packages.
Command line pip Install Pycrypto ... You find it seems to have an error, it is because this bag has not been maintained, do not worry that everything is in control!!!
After reviewing a large amount of information, we found that after this package, a new package----pycryptodome--------
Pip install Pycrypto Ann on the line, congratulations on your success.
ImportBase64 fromCrypto.cipherImportAES#STR is not a multiple of 16 then it is a multiple of 16.defadd_to_16 (value): whileLen (value)% 16! =0:value+=' /' returnStr.encode (value)#back to bytesKey='123456' #Passwordtext='abc123def456' #Text to encryptAES= Aes.new (Add_to_16 (key), AES. MODE_ECB)#Initialize the encryption deviceEncrypted_text= str (base64.encodebytes (Aes.encrypt (add_to_16 (text))), encoding='Utf-8'). Replace ('\ n',"')#perform encryption and transcode back to bytesPrint(Encrypted_text)
Attach the test code.
Python AES encryption and decryption Pycryptodome