On Feb 2, 5:47 pm, Chirag Shah <[email protected]> wrote:
> Hi Jeffery,
>
> Thanks for your reply but i want to clarify one more thing.
> If i have binary data buffer / file length is of i.e. 50 bytes, then
> do i need to take care of chopping my data in 16 bytes for first three
> Put() calls with NO_PADDING and last Put() call with padding enabled
> OR i can simply give 50 byte buffer into Put() call with padding
> enabled as its(50) not multiple of 16.
    // const size_t size = 16 * 4 + 1;
    const size_t size = 16 * 4;
    string plain(size, 0x00);

    for(size_t i = 0; i < size; i++)
        plain[i] = 'A' + (i%26);

    // cout << plain << endl;

   byte key[AES::DEFAULT_KEYLENGTH], iv[AES::BLOCKSIZE];
   memset(key, 0x00, sizeof(key));
   memset(iv, 0x00, sizeof(iv));

   CBC_Mode < AES >::Encryption aes(key, sizeof(key), iv);
   StreamTransformationFilter encryptor(
     aes, NULL, BlockPaddingSchemeDef::NO_PADDING
    );

    for(size_t j = 0; j < size; j++)
        encryptor.Put((byte)plain[j]);

    encryptor.MessageEnd();
    size_t ready = encryptor.MaxRetrievable();

    // cout << ready << endl;

    string cipher(ready, 0x00);
    encryptor.Get((byte*) &cipher[0], cipher.size());

-- 
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.

Reply via email to