Why I am not able to decrypt what I encrypted with pycrypto?
Question: Here's my code:

Encrypt:

    
    
    from Crypto.Cipher import AES
    import base64
    
    def encryption (privateInfo):
        BLOCK_SIZE = 16
        PADDING = '{'
        pad = lambda s: s + (BLOCK_SIZE - len(s) % BLOCK_SIZE) * PADDING
        EncodeAES = lambda c, s: base64.b64encode(c.encrypt(pad(s)))
        secret = 'Fr3@k1nP@ssw0rd.'
        print('encryption key:', secret)
        cipher = AES.new(secret)
        encoded = EncodeAES(cipher, privateInfo)
        print('Encrypted string:', encoded)
    
    encryption('secret')
    

The encrypted string is: b'QuCzNmwiVaq1uendvX7P+g=='

Decrypt:

    
    
    from Crypto.Cipher import AES
    import base64
    
    def decryption(encryptedString):
        PADDING = '{'
        DecodeAES = lambda c, e: c.decrypt(base64.b64decode(e)).rstrip(PADDING)
        key = 'Fr3@k1nP@ssw0rd.'
        cipher = AES.new(key)
        decoded = DecodeAES(cipher, encryptedString)
        print(decoded)
    
    decryption("b'QuCzNmwiVaq1uendvX7P+g=='")
    

The result:

    
    
    ValueError: Input strings must be a multiple of 16 in length
    

This is PyCrypto 2.6.1 on Python 3.4; I've installed VC++ 2010 Express as
well. What's really confusing me is that it works perfectly on Python 2.7

Any suggestion appreciated, but note that I'm new to Python.


Answer: Maybe because you have `"` around `"b'QuCzNmwiVaq1uendvX7P+g=='"`.

Change

`decryption("b'QuCzNmwiVaq1uendvX7P+g=='")`

to

`decryption(b'QuCzNmwiVaq1uendvX7P+g==')`

and you should be all set.

