code_junkie

Generating Random Passwords

Nov 10th, 2011
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. Guid.NewGuid().ToString("d").Substring(1,8)
  2.  
  3. public string CreatePassword(int length)
  4. {
  5. string valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
  6. string res = "";
  7. Random rnd = new Random();
  8. while (0 < length--)
  9. res += valid[rnd.Next(valid.Length)];
  10. return res;
  11. }
  12.  
  13. string[] words = { 'bur', 'ler', 'meh', 'ree' };
  14. string word = "";
  15.  
  16. Random rnd = new Random();
  17. for (i = 0; i < 3; i++)
  18. word += words[rnd.Next(words.length)]
  19.  
  20. int numbCount = rnd.Next(4);
  21. for (i = 0; i < numbCount; i++)
  22. word += (2 + rnd.Next(7)).ToString();
  23.  
  24. return word;
  25.  
  26. string password = Guid.NewGuid().ToString().ToLower()
  27. .Replace("-", "").Replace("l", "").Replace("1", "").Replace("o", "").Replace("0","")
  28. .Substring(0,10);
Add Comment
Please, Sign In to add comment