title: Generated encrypted string does not have same size in PyCrypto and Crypto++
body: <p>I recently used a Python script to encrypt a string. But could not decrypt it in C++ using Crypto++. I just compared generated encrypted strings and found they are not the same. Anybody can help?</p>
  
  <p>Here is my Python code:</p>
  
  <pre><code>key  = "0123456789abcdef"
  data = "ccccccccccccccccdddddddddddddddd"
  iv = "aaaaaaaaaaaaaaaa"
  encryptor = AES.new(key, AES.MODE_CBC, iv)
  enc = encryptor.encrypt(data)
  print enc
  </code></pre>
  
  <p>Here is my C++ code:</p>
  
  <pre><code>std::string key = "0123456789abcdef";
  std::string iv  = "aaaaaaaaaaaaaaaa";
  
  
  std::string plaintext = "ccccccccccccccccdddddddddddddddd";
  std::string ciphertext;
  std::string decryptedtext;
  
  std::cout &lt;&lt; "Plain Text (" &lt;&lt; plaintext.size() &lt;&lt; " bytes)" &lt;&lt; std::endl;
  std::cout &lt;&lt; plaintext;
  std::cout &lt;&lt; std::endl &lt;&lt; std::endl;
  
  CryptoPP::AES::Encryption aesEncryption((byte *)key.c_str(), CryptoPP::AES::DEFAULT_KEYLENGTH);
  CryptoPP::CBC_Mode_ExternalCipher::Encryption cbcEncryption( aesEncryption, (byte *)iv.c_str() );
  
  CryptoPP::StreamTransformationFilter stfEncryptor(cbcEncryption, new CryptoPP::StringSink( ciphertext ) );
  stfEncryptor.Put( reinterpret_cast&lt;const unsigned char*&gt;( plaintext.c_str() ), plaintext.length() + 1 );
  stfEncryptor.MessageEnd();
  
  std::cout &lt;&lt; "Cipher Text (" &lt;&lt; ciphertext.size() &lt;&lt; " bytes)" &lt;&lt; std::endl;
  
  for( int i = 0; i &lt; ciphertext.size(); i++ ) {
  
      std::cout &lt;&lt; "0x" &lt;&lt; std::hex &lt;&lt; (0xFF &amp; static_cast&lt;byte&gt;(ciphertext[i])) &lt;&lt; " ";
  }
  
  CryptoPP::AES::Decryption aesDecryption((byte *)key.c_str(), CryptoPP::AES::DEFAULT_KEYLENGTH);
  CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcDecryption( aesDecryption, (byte *)iv.c_str() );
  
  CryptoPP::StreamTransformationFilter stfDecryptor(cbcDecryption, new CryptoPP::StringSink( decryptedtext ) );
  stfDecryptor.Put( reinterpret_cast&lt;const unsigned char*&gt;( ciphertext.c_str() ), ciphertext.size() );
  stfDecryptor.MessageEnd();
  
  std::cout &lt;&lt; "Decrypted Text: " &lt;&lt; std::endl;
  std::cout &lt;&lt; decryptedtext;
  std::cout &lt;&lt; std::endl &lt;&lt; std::endl;
  </code></pre>