From Crypto++ Wiki
Jump to navigation Jump to search


In the pipelining paradigm, RandomNumberSources serve as an origin of data.


The example below places 8 random bytes of data into a StringSink after Hex Encoding. The code uses a StringSink and string to hold sensitive material. Though convenient, the practice is not a very good idea - see Keys and Formats for details.

AutoSeededRandomPool rng;

RandomNumberSource( rng, 8, true,
   new HexEncoder(
      new CryptoPP::StringSink( s )
   ) // HexEncoder
); // RandomNumberSource