On Tuesday, December 22, 2015 at 2:32:32 AM UTC-5, Jeffrey Walton wrote:
>
>
> int main(int argc, char* argv[])
> {
>   static const unsigned int BIG_SIZE = 2U * 1024U * 1024U * 1024U;
>   static const unsigned int BLOCK_SIZE = 4096U;
>
>   try
>   {
>     SecByteBlock key(32);
>     OS_GenerateRandomBlock(false, key.data(), key.size());
>   
>     cout << "Key: ";
>     ArraySource as(key.data(), key.size(), true, new HexEncoder(new 
> FileSink(cout)));
>     cout << endl;
>
>     CFB_Mode<AES>::Encryption enc;
>     enc.SetKeyWithIV(key.data(), key.size(), key.data());
>
>     MeterFilter* meter;
>     StreamTransformationFilter stf(enc, meter = new MeterFilter(new 
> FileSink("null.enc")));
>   
>     SecByteBlock data(BLOCK_SIZE);
>     memset(data, 0x00, data.size());
>
>     unsigned int remaining = BIG_SIZE;
>     while(remaining)
>     {
>       if(remaining % (1024*1024) == 0)
>       {
>         cout << "Processed: " << meter->GetTotalBytes();
>         cout << ", Available: " << stf.MaxRetrievable() << endl;
>       }
>
>       const unsigned int req = STDMIN(remaining, BLOCK_SIZE);
>       stf.Put(data, req);
>       stf.Flush(false);
>
>       remaining -= req;
>     }
>   }
>   catch(const Exception& ex)
>   {
>     cerr << ex.what() << endl;
>   }
>
>   return 0;
> }
>

This might be a little closer to what you are doing:

    MeterFilter* meter;
    StreamTransformationFilter* stf;

    FileSource fs("/dev/zero", false, stf = new 
StreamTransformationFilter(enc, meter = new MeterFilter(new 
FileSink("/dev/null"))));

    unsigned int remaining = BIG_SIZE;
    while(remaining)
    {
      if(remaining % (1024*1024) == 0)
      {
        cout << "Processed: " << meter->GetTotalBytes();
        cout << ", Available: " << stf->MaxRetrievable() << endl;
      }

      const unsigned int req = STDMIN(remaining, BLOCK_SIZE);
      fs.Pump(req);
      remaining -= req;
    }

Jeff 

-- 
-- 
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.
--- 
You received this message because you are subscribed to the Google Groups 
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to