-
-
Save DeebiKaaRaviSankar/4da669cf5c0f30e1e372b611d1c2d297 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public string GenerateOTP(User user, int OTPLength) | |
{ | |
string[] AllowedCharacters = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }; | |
string OTP = String.Empty; | |
string sTempChars = String.Empty; | |
Random rand = new Random(); | |
for (int i = 0; i < OTPLength; i++) | |
{ | |
int p = rand.Next(0, AllowedCharacters.Length); | |
sTempChars = AllowedCharacters[rand.Next(0, AllowedCharacters.Length)]; | |
OTP += sTempChars; | |
} | |
if (user.EmailValidationToken == OTP) | |
{ | |
GenerateOTP(user, OTPLength); | |
} | |
return OTP; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment