ok, i'm going to use an StreamTransformationFilter.
byte key[]=
{'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
byte iv[]=
{'1','2','3','4','5','6','7','8','9','0','a','b','c','d','e','f'};
//
// String and Sink setup
//
std::string plaintext = "Now is the time for all .";
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::DES::Encryption desEncryption(key,
CryptoPP::DES::DEFAULT_KEYLENGTH);
CryptoPP::CBC_Mode_ExternalCipher::Encryption cbcEncryption
( desEncryption, iv );
CryptoPP::StreamTransformationFilter stfEncryptor(cbcEncryption,
new CryptoPP::StringSink( ciphertext ) );
stfEncryptor.Put( reinterpret_cast<const unsigned char*>
( plaintext.c_str() ), plaintext.length() + 1 );
stfEncryptor.MessageEnd();
//
// Dump Cipher Text
//
std::cout << "Cipher Text (" << ciphertext.size() << " bytes)" <<
std::endl;
for( int i = 0; i < ciphertext.size(); i++ ) {
std::cout << std::hex << (0xFF & static_cast<byte>(ciphertext
[i])) ;
}
std::cout << std::endl << std::endl;
it doesn't work.
Thanks anyway Geoff , but i really don't know why it's not working
well. Encrpytion text is limited with the param 64.. so which 56 bytes
do you refer to?
On 4 ene, 02:25, Geoff Beier <[email protected]> wrote:
> Hi,
>
> I haven't built or run your code. But here:
>
> > byte PlainText[]= { 0x4e , 0x6f , 0x77 ,0x20, 0x69, 0x73 ,0x20 ,
> > 0x74} ;
> > byte cbCipherText[ 64 ] ;
> > CryptoPP::ECB_Mode< CryptoPP::DES >::Encryption Encryptor;
> > Encryptor.SetKey( key, 8);
> > Encryptor.ProcessData( cbCipherText,PlainText, 64);
>
> you would appear to be encrypting whatever 56 bytes follow your
> plaintext on the stack in addition to your plaintext.
>
> http://www.cryptopp.com/docs/ref/class_symmetric_cipher.html
>
> HTH,
>
> Geoff
--
You received this message because you are subscribed to the "Crypto++ Users"
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at
http://www.cryptopp.com.