public static string GenerateRandomDigitCode(int length) { using var random = new SecureRandomNumberGenerator(); var str = string.Empty; for (var i = 0; i < length; i++) { str = string.Concat(str, random.Next(10).ToString()); } return(str); }
public static int GenerateRandomInteger(int min = 0, int max = int.MaxValue) { using var random = new SecureRandomNumberGenerator(); return(random.Next(min, max)); }