title: AES encryption issue: "ValueError: Input strings must be a multiple of 16 in length"
body: <p>I was trying to encrypt some sensitive data inside the database using AES by this python code </p>
  
  <pre><code>from Crypto.Cipher import AES
  import base64
  import pymysql
  import os
  import hashlib    
  
  def encryption(self, tableName):
      # opening db connection
      db_connection = self.getMySqlConnection()
      cursor = db_connection.cursor()
  
      print("\tTwo Way Encryption")
  
      # hashing
      cursor.execute("SELECT toMask FROM " + tableName + ";")
      row = cursor.fetchall()
      for item in row:
          string = str(item[0])
          padded = string.rjust(80)
          secret_key = self.key
          cipher = AES.new(secret_key, AES.MODE_ECB)
          encoded = base64.b64encode(cipher.encrypt(padded))
          encoded = encoded.decode('utf-8')
          stmt = "update " + tableName + " set toMask = '" + encoded + "' where toMask =\"" + string + "\";"
          cursor.execute(stmt)
          db_connection.commit()
  
      # closing db connection
      db_connection.close()
  
      print("\tDone")
  </code></pre>
  
  <p>But my data contains some special characters like this </p>
  
  <blockquote>
    <p>Å</p>
  </blockquote>
  
  <p>So I am getting this error: </p>
  
  <p><code>ValueError: Input strings must be a multiple of 16 in length</code></p>
  
  <p>How can I solve this? Other input string doesn't make any issues.</p>
  
  <p>Or do I need to convert that to any other encoding?</p>