I'm doing this assignment and i came across this problem where if i input a sentence, eg: "Hello my name is Adam", it will only encrypt "Hello".. But when i assign the sentence to the plaintext, I get a full encrypted/decrypted sentence.
AutoSeededRandomPool rnd;
// Generate a random key
SecByteBlock key(0x00, AES::DEFAULT_KEYLENGTH);
rnd.GenerateBlock( key, key.size() );
// Generate a random IV
SecByteBlock iv(AES::BLOCKSIZE);
rnd.GenerateBlock(iv, iv.size());
// Read phrase
std::string plaintext;
cin >> plaintext;
std::string ciphertext;
std::string decryptedtext;
// encrypt
CTR_Mode<AES>::Encryption cfbEncryption(key, key.size(), iv);
CryptoPP::StreamTransformationFilter stfEncryptor(cfbEncryption, new CryptoPP::StringSink( ciphertext ) );
stfEncryptor.Put( reinterpret_cast<const unsigned char*>( plaintext.c_str() ), plaintext.length() + 1 );
stfEncryptor.MessageEnd();
cout << ciphertext << endl;
// decrypt
CTR_Mode<AES>::Decryption cfbDecryption(key, key.size(), iv);
CryptoPP::StreamTransformationFilter stfDecryptor(cfbDecryption, new CryptoPP::StringSink( decryptedtext ) );
stfDecryptor.Put( reinterpret_cast<const unsigned char*>( ciphertext.c_str() ), ciphertext.size() );
stfDecryptor.MessageEnd();
cout << decryptedtext << endl;
Can someone explain..? I don't quite understand how this works... I need user input for this assignment. Is there a way where i can have user input and get the full encrypted sentence?