title: Problems with CryptoPP C++ AES-256+Base64
body: <p>could someone please tell me as to why the decryption starts to mess up. It works fine with short strings but it will mess up as you can see as it goes on. I THINK it has something to do with the string conversions.</p>
  
  <pre><code>std::string encrypt(const std::string&amp; str_in, const std::string&amp; key, const std::string&amp; iv)
  {
  
      std::string str_out;
      CryptoPP::CFB_Mode&lt;CryptoPP::AES&gt;::Encryption encryption((byte*)key.c_str(),    key.length(), (byte*)iv.c_str());
      CryptoPP::StringSource encryptor(str_in, true,
          new CryptoPP::StreamTransformationFilter(encryption,
              new CryptoPP::Base64Encoder(
                  new CryptoPP::StringSink(str_out),
                  false // do not append a newline
              )
          )
      );
      return str_out;
  }
  
  
  std::string decrypt(const std::string&amp; str_in, const std::string&amp; key, const std::string&amp; iv)
  {
  
      std::string str_out;    
      CryptoPP::CFB_Mode&lt;CryptoPP::AES&gt;::Decryption decryption((byte*)key.c_str(), key.length(), (byte*)iv.c_str());
  
      CryptoPP::StringSource decryptor(str_in, true,
          new CryptoPP::Base64Decoder(
              new CryptoPP::StreamTransformationFilter(decryption,
                  new CryptoPP::StringSink(str_out)
              )
          )
      );
      return str_out;
  }
  </code></pre>
  
  <p>This would be my output of the program</p>
  
  <pre><code>key:qwertyuiopasdfghjklzxcvbnmqwerty
  IV:0123456789123456
  
  STR:I do not like green eggs and ham I do not like them Sam-I-Am. Try them, try them, and you may! Try them and you may, I say. I will not eat them in a house, i will not eat them with a mouse,i will not eat them in a box i will not eat them with a fox, i will not eat them here of there i will not eat them anywhere, I do not like green eggs and ham i do not like them sam i am
  
  STR_ENCRYPTED: ffyHj0rFQ0fn+jJcuZAznaioo+2oqqq+7ayjqe2lrKBF8s6QLdosGuIXzz/+vL+Bz
  c3Nzc3Nzc3Nzc3Nzc3Nzd78yyKlu7P47yMSlKi7AhEyLs55pj9nZcEIPPadhISD4bQSGVWiWGbEMr7Ev
  UCA+f9XQnePvQrfDwpegOLwYk8YyjXa9rLprhk7gAOU4LcdSRT6Udgohsolvrick6CSyUB9gJmkK6Ng1
  MjSw4zBQkYMmt7oobkObBQY5XJHcTX5fVGXE5MJsVkQqGqAAKwD6jq4yZcG26WfA9LkwVgj0AwpxjKGV
  VeYM/HKK9gzDA9u0/x0y/H4be8rpOYXPyrxXB8++iBL6cFz/Hq+y37uznfmqgAFdTkoW9FsHcGfmxZpJ
  PYqrPKKwbt0EuMVGT1Z1F8kgvnwGiAg7/t7oa8RFStF3dsBd5LIYujx0nbnebSrkAFR0qMPzMDF4+Pox
  n8KaEm6dtRYGEyYBfJWju+kWqug7aTtrKA=
  
  
  STR_DECRYPTED: I do not like green eggs and ham I do not like t                y
   them, try them π♥┤k≥¬¿♀┼±;PIINry them and you 2ÜÅ║Bp╟↕┬╟ôM/=»éll not eat them ä
  ┘7£§σKΦsuQ^m_♦ll not eat them ┴W‼%lt├í┘╒(┐è╝°4ill not eat them≈u♦Z╦▬hR╬▼)♀òε↔┴ n
  ot eat them wi▲1╣♠&lt;5á"µi+┌≥τ&lt;æ not eat them he+g═╚╕⌠σû∟í╨♀RV█ñll not eat them ÆΘ
  ..%♂▓╟Ñnot like them sam i amg]╠£▼n┬☺
  Press any key to continue . . .
  </code></pre>
  
  <h3>EDIT</h3>
  
  <p>This is how I call the code in my program, I use a liscensed version of Visual Studio 2012 on Windows 7.</p>
  
  <pre><code>std::string szEncryptionKey= "qwertyuiopasdfghjklzxcvbnmqwerty";;
  std::string szEncryptionIV= "0123456789123456";
  std::string str="I do not like green eggs and ham I do not like them Sam-I-Am. Try them, try them, and you may! Try them and you may, I say. I will not eat them in a house, i will not eat them with a mouse,i will not eat them in a box i will not eat them with a fox, i will not eat them here of there i will not eat them anywhere, I do not like green eggs and ham i do not like them sam i am";
  std::string str_encrypted = encrypt(str, szEncryptionKey, szEncryptionIV);
  std::string str_decrypted = decrypt(str_encrypted, szEncryptionKey, szEncryptionIV);
  
  std::cout&lt;&lt; "str encrypted: "&lt;&lt;str_encrypted&lt;&lt;std::endl;
  std::cout&lt;&lt; "str decrypted: "&lt;&lt;str_decrypted&lt;&lt;std::endl;
  </code></pre>