Today needs to use AES CBC mode encryption, search for a long time, finally encryption success, record today's understanding.
First to install the Pycrypto library, do not know why the Windows installation fails, the Linux can be installed properly
Http://tool.chacuo.net/cryptaes,https://tools.lami.la/jiami/aes, the following code is encrypted after the result is the same as the two pages are encrypted.
Here are a few points to note, the length of the key if the length of the 16,24 or 32,text 16 multiples, do not meet the length will be complete, complete the character can be defined by themselves, such as key complement does not have to "" ", you can also use other, text complement the character in your decryption will be used,
However, the following completion of the characters should be the same as the above two URL completion of the same character.
#-*-encoding:utf-8-*- fromCrypto.cipherImportAESImportbase64bs=aes.block_size # This equals 16mode .=AES. Mode_cbcpad=LambdaS:s + (Bs-len (s)) *" /" #used to complete key#used to fill the text below, the above two URLs are complete with the following formPad_txt =LambdaS:s + (Bs-len (s)% BS) * CHR (Bs-len (s)%BS) Unpad=LambdaS:s[0:-ord (s[-1])]key="123" #The length can (+, +) # keyText ='http://www.baidu.com/' #Encrypt textVI ="Hjrp7llxussfmisz" #Offset Amountcipher=aes.new (Pad (key), mode, vi) encrypted=Cipher.encrypt (Pad_txt (text))#encrypted by AES, then base64 encryptionencrypted =Base64.b64encode (encrypted)Print(encrypted) Cryptor=aes.new (Pad (key), mode, vi)#decryption, after decryption, the text will contain the characters used to complete the completionPlain_text =Cryptor.decrypt (Base64.b64decode (encrypted))Print(Plain_text)
Python AES CBC mode encryption