title: RNGCryptoServiceProvider - Random Number Review
body: <p>While looking for best attempts at generating truly random numbers, I stumbled upon this code example.</p>
  <p>Looking for opinions on this snippet.</p>
  <pre><code>using System;
  using System.Security.Cryptography;
  
  private static int NextInt(int min, int max)
  {
      RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
      byte[] buffer = new byte[4];
      
      rng.GetBytes(buffer);
      int result = BitConverter.ToInt32(buffer, 0);
  
      return new Random(result).Next(min, max);
  }
  </code></pre>
  <p>Source: <a href="http://www.vcskicks.com/code-snippet/rng-int.php" rel="nofollow noreferrer">http://www.vcskicks.com/code-snippet/rng-int.php</a></p>
  <p>Would this be preferred over using a tick count seed such as:</p>
  <pre><code>Random rand = new Random(Environment.TickCount); 
  rand.Next(min, max);
  </code></pre>
  <p><strong>Note:</strong></p>
  <p>I am not looking for third party random data providers such as <a href="http://Random.org" rel="nofollow noreferrer">Random.org</a>, as such a dependency is not realistic to the application.</p>