Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3.  
  4. namespace serkoklausur
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. Console.WriteLine("Kennwortlänge: ");
  11. int lang = Convert.ToInt32(Console.ReadLine());
  12. Console.WriteLine("Anzahl der Passwörter: ");
  13. int anzahl = Convert.ToInt32(Console.ReadLine());
  14. Console.WriteLine("Komplexität");
  15. int input = Convert.ToInt32(Console.ReadLine());
  16.  
  17. //klein u. großbuchstabe
  18. const string smallChars = "abcdefghijklmnopqrstuvwxyz";
  19. const string capitalChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  20. //zusätzlich zahlen
  21. const string zahlen = "123456789";
  22. //zusätzlich sonderzeichen
  23. const string sonderzeichen = "_<>?\\/#&$";
  24.  
  25. string possibleChars = null;
  26.  
  27. if (input == 1)
  28. {
  29. possibleChars = smallChars + capitalChars;
  30. }
  31. else if (input == 2)
  32. {
  33. possibleChars = smallChars + capitalChars + zahlen;
  34. }
  35. else if (input == 3)
  36. {
  37. possibleChars = smallChars + capitalChars + zahlen + sonderzeichen;
  38. }
  39.  
  40. Random rnd = new Random();
  41.  
  42. for (int i = 0; i < anzahl; i++)
  43. {
  44. StringBuilder password = new StringBuilder();
  45. for (int a = 0; a < lang; a++)
  46. {
  47. password.Append(possibleChars[rnd.Next(possibleChars.Length)]);
  48. }
  49. Console.WriteLine(password);
  50. }
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement