Advertisement
Guest User

Password Generator

a guest
Jul 20th, 2021
906
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.36 KB | None | 0 0
  1. # These imports are important.
  2. import random
  3. import string
  4. import sys
  5. import os
  6.  
  7. # We will use string module as it will make our work easy.
  8. os.system("title Password Generator.")
  9.  
  10. # This function will be used to create some random and strong passwords.
  11. def GeneratePass(PassLen):
  12.     # We used the Characters from the Greatful ASCHII Table,
  13.     # this made our work easier.
  14.     # Break it into a list.
  15.     Chars = list(string.ascii_letters + string.digits + string.punctuation)
  16.  
  17.     # We got it but it's not that secure,
  18.     # let's make it secure.
  19.  
  20.     # This will shuffle all the items in the list and place then randomly.
  21.     random.shuffle(Chars)
  22.  
  23.     # Let's print our password.
  24.     # Now are password should be random and strong.
  25.     Password = "".join(Chars[:PassLen])
  26.     print(f"Your password is: {Password}")
  27.     input("Continue.")
  28.  
  29. # Create a if statement asking for the length of your password.
  30. # If the input is not a number then throw error.
  31. PasswordLength = input("Enter your Password Length: ")
  32. if PasswordLength.isdigit() == False:
  33.     print("It's not a valid number.")
  34.  
  35. else:
  36.     GeneratePass(int(PasswordLength))
  37.  
  38. sys.exit() # Exit the program.
  39.  
  40. # AND IT'S DONE!!!
  41. # YOU HAVE CREATED YOUR VERY OWN PASSWORD GENERATOR.
  42. # THIS PASSWORD GENERATOR IS NOT VERY GOOD BUT IT DOES A DECENT JOB.
  43. # HAVE FUN!
  44. # THANKS FOR WATCHING, AND PLEASE LEAVE A LIKE, AND SUBSCRIBE IF YOU ARE NEW...
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement