Kxffie

Python Password Generator v2

Jan 29th, 2022
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. from tinydb import TinyDB
  2. db = TinyDB('./db.json')
  3.  
  4. import random
  5. import string
  6. import time
  7.  
  8. print("Password Generator\n*NOTE - in Pass Gen v2, if you decide to make multiple passwords at once, it only saves the last one\n\n\tMade by Kxffie\n")
  9. time.sleep(1)
  10.  
  11. profileName = input("What profile would you want to save this to? (i.e. Minecraft Password): ")
  12.  
  13. passLimit = int(input("How long do you want your password(s) to be: "))
  14. passAmount = int(input("How many passwords do you want: "))
  15.  
  16. options = int(input("Options:\n"+"\t1. Just Letters \t2. Letters & Numbers \t3. Letters, Numbers & Punctiation: "))
  17.  
  18. def insert():
  19. if(options == 1):
  20. for i in range(passAmount):
  21. randomChar = ''.join(random.sample(string.ascii_letters, k=passLimit))
  22. print(randomChar)
  23. elif(options == 2):
  24. for i in range(passAmount):
  25. randomChar = ''.join(random.sample(string.ascii_letters + string.digits + string.octdigits, k=passLimit))
  26. print(randomChar)
  27. elif(options == 3):
  28. for i in range(passAmount):
  29. randomChar = ''.join(random.sample(string.ascii_letters + string.punctuation + string.hexdigits + string.octdigits + string.digits, k=passLimit))
  30. print(randomChar)
  31.  
  32. db.insert({'profile': profileName, 'password': ''.join(randomChar)})
  33.  
  34. insert()
  35.  
  36. time.sleep(1)
  37. input("\nPress Enter to exit...")
Advertisement
Add Comment
Please, Sign In to add comment