Share Blog

Thursday, July 19, 2018

How to Generate OTP and Random Number in C#


private static string GenerateOTP()
{
Random generator = new Random();
String r = generator.Next(0, 1000000).ToString("D6");
if (r.Distinct().Count() == 1)
{
r = GenerateOTP();
}
return r;
}

No comments:

Post a Comment