title: How to generate random 6 digit which expire after 5 second?
body: <p>I got a logic which generate a 6 digit number which remain constant up to 5 sec. Here is the code. The problem is the below routine generate number sequentially which I do not want rather I want dynamic that any user can not guess what will be the next number. </p>
  
  <pre><code>public static int GetTimestamp()
  {
      // 10m ticks in a second, so 50m in 5 seconds
      const int ticksIn5Seconds = 50000000;
      return (int)((DateTime.Now.Ticks / ticksIn5Seconds) % 1000000);
  }
  </code></pre>
  
  <p>Here another code which Generate Unique 8 digit Number in C#.</p>
  
  <pre><code>public string Get8Digits()
   {
     var bytes = new byte[4];
     var rng = RandomNumberGenerator.Create();
     rng.GetBytes(bytes);
     uint random = BitConverter.ToUInt32(bytes, 0) % 100000000;
     return String.Format("{0:D8}", random);
   }
  </code></pre>
  
  <p>I try to combine both the logic to generate random 6 digit number which may not be guessed what next 6 digit number will be generated. Looking for guidance what should I do to achieve my objective. Thanks.</p>