I tried to make a program that will encrypt some string with 256 AES. But I'm not able to decrypt it.
Here is the code
from Crypto.Cipher import AES
from Crypto import Random
import os, base64
block_size = 32
def pad(s):
return s + "\0" * (block_size - len(s) % block_size)
key = os.urandom(block_size)
iv = Random.new().read(AES.block_size)
cipher = AES.new(key, AES.MODE_CBC, iv)
enc = cipher.encrypt(pad('Hello World'))
print 'Encrypted', enc
iv = enc[:AES.block_size]
key = os.urandom(block_size)
cipher = AES.new(key, AES.MODE_CBC, iv)
dec = cipher.decrypt(enc[block_size:])
dec_rstrip = dec.rstrip("\0")
print 'Decrypted', dec_rstrip