Skip to content

Instantly share code, notes, and snippets.

@ADelRosarioH
Created May 22, 2014 19:25
Show Gist options
  • Save ADelRosarioH/9219f619e79c3ded170a to your computer and use it in GitHub Desktop.
Save ADelRosarioH/9219f619e79c3ded170a to your computer and use it in GitHub Desktop.
Generate random digits
public string digits()
{
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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment