Hi all,
You guys might have applied for any online exams where after the submission a registeration ID(which is a 6-7 digit) and a alpha numeric password.. How to generate alpha numeric password ????? Plzz help me
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Feb 15, 2011, 5:35 AM EST
public static string CreateRandomPassword(int PasswordLength)
{
string _allowedChars = "0123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ";
Random randNum = new Random();
char[] chars = new char[PasswordLength];
int allowedCharCount = _allowedChars.Length;
for (int i = 0; i < PasswordLength; i++)
{
chars[i] = _allowedChars[(int)((_allowedChars.Length) * randNum.NextDouble())];
}
return new string(chars);
}
If you feel this is correct what you need, please make this as Accepted Answer.
Thanks.
Kavita B135 reputationPosted Feb 15, 2011, 4:51 PM EST
Here ALPHA NUMERIC password is generated AUTOMATICALLY by the system for the people who have registered so that they can use it in future to download the application etc...
Sam HobbsRank #107 · 20.5K reputationPosted Feb 15, 2011, 7:16 PM EST
Suthish NairRank #92 · 22.8K reputationPosted Feb 15, 2011, 10:21 PM EST
Do you want to create it from code behind or sql backend.
From SQL: select SUBSTRING(CONVERT(varchar(255), NEWID()), 0, 7)
Kavita B135 reputationPosted Feb 16, 2011, 2:13 AM EST
My problem here is:
I want to give the user a registertaion ID and a password(which is a ALPHA NUMERIC PASSWORD) and these 2 should be UNIQUE after the user has submitted an online application...
How do i do this please help...
@ Suthish
Yes these are generated from SQL CODE BEHIND for that user and should be UNIQUE......PLEASE HELP ME FRIENDS
Suthish NairRank #92 · 22.8K reputationPosted Feb 17, 2011, 8:45 AM EST
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Feb 17, 2011, 9:56 AM EST
Functionality:
generatedPassword = CreateRandomPassword(10);
while(IsPasswordExists(generatedPassword))
generatedPassword = CreateRandomPassword(10);
Where IsPasswordExists(generatedPassword) is a method which checks for the availability of password in the database. If password is exists then it should return true.