title: ValueError: AES key must be either 16, 24, or 32 bytes long PyCrypto 2.7a1
body: <p>I'm making programm for my school project and have one problem above.
  Here's my code:</p>
  
  <pre><code>def aes():
      #aes
      os.system('cls')
      print('1. Encrypt')
      print('2. Decrypt')
  
      c = input('Your choice:')
  
      if int(c) == 1:
          #cipher
          os.system('cls')
          print("Let's encrypt, alright")
          print('Input a text to be encrypted')
          text = input()
  
          f = open('plaintext.txt', 'w')
          f.write(text)
          f.close()
  
          BLOCK_SIZE = 32
          PADDING = '{'
          pad = lambda s: s + (BLOCK_SIZE - len(s) % BLOCK_SIZE) * PADDING
          EncodeAES = lambda c, s: base64.b64encode(c.encrypt(pad(s)))
          secret = os.urandom(BLOCK_SIZE)
  
          f = open('aeskey.txt', 'w')
          f.write(str(secret))
          f.close()
  
          f = open('plaintext.txt', 'r')
          privateInfo = f.read()
          f.close()
  
          cipher = AES.new(secret)
  
          encoded = EncodeAES(cipher, privateInfo)
  
          f = open('plaintext.txt', 'w')
          f.write(str(encoded))
          f.close()
          print(str(encoded))
  
      if int(c) == 2:
          os.system('cls')
          print("Let's decrypt, alright")
  
          f = open('plaintext.txt','r')
          encryptedString = f.read()
          f.close()
  
          PADDING = '{'
          DecodeAES = lambda c, e: c.decrypt(base64.b64decode(e)).rstrip(PADDING)
          encryption = encryptedString
  
          f = open('aeskey.txt', 'r')
          key = f.read()
          f.close()
  
          cipher = AES.new(key)
          decoded = DecodeAES(cipher, encryption)
  
          f = open('plaintext.txt', 'w')
          f.write(decoded)
          f.close()
  
          print(decoded)
  </code></pre>
  
  <p>Full error text:</p>
  
  <pre><code>Traceback (most recent call last): File "C:/Users/vital/Desktop/Prog/Python/Enc_dec/Enc_dec.py", line 341, in aes() 
  File "C:/Users/vital/Desktop/Prog/Python/Enc_dec/Enc_dec.py", line 180, in aes cipher = AES.new(key) 
  File "C:\Users\vital\AppData\Local\Programs\Python\Python35-32\lib\site-packages\Crypto\Cipher\AES.py", line 179, in new return AESCipher(key, *args, **kwargs) 
  File "C:\Users\vital\AppData\Local\Programs\Python\Python35-32\lib\site-packages\Crypto\Cipher\AES.py", line 114, in init blockalgo.BlockAlgo.init(self, _AES, key, *args, **kwargs) 
  File "C:\Users\vital\AppData\Local\Programs\Python\Python35-32\lib\site-packages\Crypto\Cipher\blockalgo.py", line 401, in init self._cipher = factory.new(key, *args, **kwargs)
  ValueError: AES key must be either 16, 24, or 32 bytes long
  
  Process finished with exit code 1
  </code></pre>
  
  <p>What am I doing wrong?</p>