Advertisement
crissgod

First C# PassGen / Criss

Sep 18th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace PassGen
  8. {
  9. class Program
  10. {
  11. static string generatePswd(int lenght)
  12. {
  13. const string validChars = "1234567890qwertyuiopasdfghjklzxcvbnm";
  14. StringBuilder res = new StringBuilder();
  15. Random rnd = new Random();
  16. while (0 < lenght--)
  17. {
  18.  
  19. res.Append(validChars[rnd.Next(validChars.Length)]);
  20. }
  21. return res.ToString();
  22. }
  23. static void Main(string[] args)
  24. {
  25. //password lenght
  26. int lenght = 10;
  27.  
  28. string pass = generatePswd(lenght);
  29. Console.Write(pass);
  30.  
  31.  
  32.  
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement