title: There's an error with decryption of the message encrypeted through AES-256 after sending
body: <p>I use AES-256 refer
  <a href="https://stackoverflow.com/questions/12524994/encrypt-decrypt-using-pycrypto-aes-256">Encrypt &amp; Decrypt using PyCrypto AES 256</a>. However there is a some error while decoding.</p>
  <pre><code>  File &quot;/home/client.py&quot;, line 60, in receive
      print('%s :' %opp_id, aes.decrypt(recvData))
    File &quot;/home/client.py&quot;, line 31, in decrypt
      return self._unpad(cipher.decrypt(enc[AES.block_size:])).decode('utf-8')
    File &quot;/home/PycharmProjects/qkd-chat/venv/lib/python3.9/site-packages/Crypto/Cipher/blockalgo.py&quot;, line 295, in decrypt
      return self._cipher.decrypt(ciphertext)
  
  
  ValueError: Input strings must be a multiple of 16 in length
  </code></pre>
  <p>The code below is part for AES-256.</p>
  <pre><code>class AESCipher(object):
      def __init__(self, key):
          self.bs = AES.block_size
          self.key = hashlib.sha256(key.encode()).digest()
  
      def encrypt(self, raw):
          raw = self._pad(raw)
          iv = Random.new().read(AES.block_size)
          cipher = AES.new(self.key, AES.MODE_CBC, iv)
          return base64.b64encode(iv + cipher.encrypt(raw.encode()))
  
      def decrypt(self, enc):
          enc = base64.b64decode(enc)
          iv = enc[:AES.block_size]
          cipher = AES.new(self.key, AES.MODE_CBC, iv)
          return self._unpad(cipher.decrypt(enc[AES.block_size:])).decode('utf-8')
  
      def _pad(self, s):
          return s + (self.bs - len(s) % self.bs) * chr(self.bs - len(s) % self.bs)
  
      @staticmethod
      def _unpad(s):
          return s[:-ord(s[len(s)-1:])]
  </code></pre>
  <p>this is the part of socket programming</p>
  <pre><code>def send(sock):
      while True:
          try:
              aes = AESCipher(key)
              sendData = aes.encrypt(input())
              # sendData = encrypt(key, input())
              sock.send(sendData)
          except:
              continue
  </code></pre>
  <pre><code>def receive(sock):
      while True:
          recvData = sock.recv(4096)
          try:
              aes = AESCipher(key)
              print('%s :' %opp_id, aes.decrypt(recvData))
          except DecryptionException as e:
              print(e)
  </code></pre>
  <p>I think there is an error in receive message because there is a some change in error message when I change the number in sock.recv( - )</p>