Yo,
Ca fait un bail que j'essaye d'encrypter des valeurs avec cryptopp mais ca n'arrête pas de crasher de manière inexplicable. Quand c'est pas cette erreur la:
Cliquez pour révéler
Cliquez pour masquer
Assertion failed: (false), function deallocate, file /usr/local/include/cryptopp/secblock.h, line 151.
c'est un malloc break error
donc voici mon code :)
Cliquez pour révéler
Cliquez pour masquer
using namespace CryptoPP;
byte key[ CryptoPP::AES::DEFAULT_KEYLENGTH ];
byte iv[ CryptoPP::AES::BLOCKSIZE ];
const char* tmp_key = m_key.data();
for (int i = 0; i < sizeof(tmp_key); i++)
key = (byte)tmp_key;
std::string plaintext = QString(m_ticket).toStdString();
std::string ciphertext;
std::string decryptedtext;
CryptoPP::AES::Encryption aesEncryption(key, CryptoPP::AES::DEFAULT_KEYLENGTH);
CryptoPP::CBC_Mode_ExternalCipher::Encryption cbcEncryption( aesEncryption, iv );
CryptoPP::StreamTransformationFilter stfEncryptor(cbcEncryption, new CryptoPP::StringSink( ciphertext ) );
stfEncryptor.Put( reinterpret_cast<const unsigned char*>( plaintext.c_str() ), plaintext.length() + 1 );
stfEncryptor.MessageEnd();
QByteArray result(ciphertext.data());
return result;