Counting bits -- Jens Weller

How to generate random bytes and how generic programming allow/support reuse code for different types.

   Counting bits

   by Jens Weller

From the article:

I did a bit of fun coding. I'm currently thinking on how to generate random bytes, for example the 16 random bytes for the initialization vector of AES. The mersenne twister RNG is known to give very good randomness, so it would be a possible an easy source. An std::array<uint32_t,4> would be a good container, filled with generate. But first, I wanted to know, how random is the mersenne twister really? So, when counting the bits in the result of a few thousand calls to a rng, the distribution should be even. So, today I wrote code that counts bits, and tested it on the mersenne twister.

 

Add a Comment

Comments are closed.

Comments (1)

1 0

Meeting C++ said on Feb 22, 2015 05:29 AM:

I removed the reference to AES, as the standard does not provide RNGs that are safe for encryption.