Advertisement
Guest User

pswrd.py

a guest
Mar 17th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.44 KB | None | 0 0
  1. import string
  2. import random
  3.  
  4. upperLetters = (string.ascii_uppercase)
  5. lowerLetters = (string.ascii_lowercase)
  6. digits       = (string.digits)
  7. specialChars = (string.punctuation)
  8.  
  9. i = 0
  10. k = 0
  11. chars = ""
  12. password = ""
  13.  
  14. print("Einfacher Passwortgenerator")
  15. print("by HeikoHDE")
  16. askLowerLetters = (str.lower(input("Sollen in Ihrem Passwort Kleinbuchstaben vorkommen? [J/N]     ")))
  17. askUpperLetters = (str.lower(input("Sollen in Ihrem Passwort Großbuchstaben vorkommen? [J/N]      ")))
  18. askDigits       = (str.lower(input("Sollen in Ihrem Passwort Zahlen vorkommen? [J/N]              ")))
  19. askSpecialChars = (str.lower(input("Sollen in Ihrem Passwort Sonderzeichen vorkommen? [J/N]       ")))
  20. askLenght       = (int(input("Aus wie vielen Zeichen soll Ihr Passwort bestehen? [1-100]    ")))
  21. askCount        = (int(input("Wie viele Passwörter sollen generiert werden? [1-100]         ")))
  22.  
  23. if (askLowerLetters == "j"):
  24.     chars += lowerLetters
  25. if (askUpperLetters == "j"):
  26.     chars += upperLetters
  27. if (askDigits == "j"):
  28.     chars += digits
  29. if (askSpecialChars == "j"):
  30.     chars += specialChars
  31. if (chars == ""):
  32.     print("Sie haben keine Zeichen gewählt, aus denen Ihr Passwort bestehen kann.")
  33.  
  34. while (i < askCount):
  35.     while (k < askLenght):
  36.         password += (random.choice(chars))
  37.         k += 1
  38.     print (password)
  39.     password = ""
  40.     k = 0
  41.     i += 1
  42. print ("Ich hoffe Ihnen hat mein kleiner Passwortgenerator gefallen.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement