Crypto ++ шифровать и дешифровать в двух разных программах на C ++

Я пишу код для шифрования и дешифрования с помощью библиотеки crypto ++. Я нашел код для шифрования и дешифрования, который показан ниже. Код работает нормально как одна программа. Но когда я делю на две программы на С ++ (одна для шифрования и другая для дешифрования ) расшифровка парграмма дает мне ошибку

terminate called after throwing an instance of 'CryptoPP::InvalidCiphertext' what(): StreamTransformationFilter: ciphertext length is not a multiple of block size

Зашифрованный текст, который я получаю после шифрования

���z=(f�����P%���2��W3�p�H�����^��@C��#������bp���nx��

который я передаю в код расшифровки. Что я делаю неправильно?

моя первая программа для шифрования

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include "crypto++/modes.h"
#include "crypto++/aes.h"
#include "crypto++/filters.h"

int main(int argc, char* argv[]) {

    //
    // Key and IV setup
    //AES encryption uses a secret key of a variable length (128-bit, 196-bit or 256-
    //bit). This key is secretly exchanged between two parties before communication
    //begins. DEFAULT_KEYLENGTH= 16 bytes
    byte key[ CryptoPP::AES::DEFAULT_KEYLENGTH ], iv[ CryptoPP::AES::BLOCKSIZE ];
    memset( key, 0x00, CryptoPP::AES::DEFAULT_KEYLENGTH );
    memset( iv, 0x00, CryptoPP::AES::BLOCKSIZE );

    //
    // String and Sink setup
    //
    std::string plaintext = "Now is the time for all good men to come to the aide...";
    std::string ciphertext;
    std::string decryptedtext;

    //
    // Dump Plain Text
    //
    std::cout < "Plain Text (" < plaintext.size() < " bytes)" < std::endl;
    std::cout < plaintext;
    std::cout < std::endl < std::endl;

    //
    // Create Cipher Text
    //
    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

Ответы на вопрос(0)

Ваш ответ на вопрос