Advertisement
Guest User

pswrd.py

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