title: Fast pseudorandom number generator for cryptography in C
body: <p>I was using the following code to generate sequence of pseudo-random numbers that was used for cryptographic purposes, but then I read somewhere that it may not be very secure. Can someone give me C implementation of a better generator -- the main goal is for this method to be fast. For instance, I did some research and came across <a href="http://en.wikipedia.org/wiki/Blum_Blum_Shub" rel="noreferrer">Blum Blum Shub</a> method, which would totally kill performance by doing pow(N) calculations.</p>
  
  <p>PS. And please don't quote Wikipedia articles w/o C/C++ code. I'm looking for C or C++ code sample of what I'm showing below.</p>
  
  <pre><code>#define ROL(v, shift) ((((v) &gt;&gt; ((sizeof(v) * 8) - (shift))) | ((v) &lt;&lt; (shift))))
  
  ULONGLONG uiPSN = doSeed();   //64-bit unsigned integer
  
  for(int i = 0; i &lt; sizeOfArray; i++)
  {
      uiPSN = uiPSN * 214013L + 2531011L;
      uiPSN = ROL(uiPSN, 16);
  
      //Apply 'uiPSN'
  }
  </code></pre>