Click here to Skip to main content
15,896,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends i want a randomly generated a password with code. Please Help me.

Thanks in advance
Posted

 
Share this answer
 
That is going to depend on what you want to include, and how strong you want to make it.

The easiest way is to get a Guid:
Guid g = Guid.NewGuid();
string s = g.ToString("D");
But it won't be easy to remember!
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 10-Jun-11 18:47pm    
Pretty simple option, my 5. When passwords are auto-generated, they are not supposed to be remembered; the users change them (to "123", usually :-))
--SA
This one is very simple

private static string CreateRandomPassword(int passwordLength)
{
 string allowedChars = "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ0123456789!@$?_-";
 char[] chars = new char[passwordLength];
 Random rd = new Random();

 for (int i = 0; i < passwordLength; i++)
 {
  chars[i] = allowedChars[rd.Next(0, allowedChars.Length)];
 }

 return new string(chars);
}


If you want to generate strong random password then follow

http://www.obviex.com/Samples/Password.aspx[^]
 
Share this answer
 
Comments
parmar_punit 10-Jun-11 9:05am    
GOOD LOGIC my 5
Kiran Sonawane 10-Jun-11 9:07am    
Thanks Dude
Sergey Alexandrovich Kryukov 10-Jun-11 18:51pm    
Simple and not bad, you could easily make if a bit stronger. My 5. Don't know about the qualify of the referenced generator, I suggested another one --
Please see my solution.
--SA
Kiran Sonawane 11-Jun-11 11:38am    
Hmmmm 5+
Sergey Alexandrovich Kryukov 12-Jun-11 22:39pm    
Hmmmm, thank you.
--SA
Just make one up. Just decide on a format for the password and write a generator for it.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 10-Jun-11 18:45pm    
Best answer so far, my 5.
--SA
Maybe strong password generator is better, this one: Strong Password Generator[^].

—SA
 
Share this answer
 
Try this link u will find solution



http://www.dotnetspark.com/kb/4158-random-password-generator.aspx
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 10-Jun-11 18:46pm    
Not very good, excessive code.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900