Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from rich.console import Console
- from rich.markdown import Markdown
- from rich.progress import track
- from rich.theme import Theme
- from tinydb import TinyDB
- db = TinyDB('./db.json')
- import time
- import random
- import string
- import json
- custom_theme = Theme({"green": "green", "red": "red"})
- console = Console()
- MARKDOWN = """
- # Kxffie's Password Generator v3
- ## Created by Kxffie\t[Kxffiehub.xyz](https://www.kxffiehub.xyz)
- """
- md = Markdown(MARKDOWN)
- console.print(md)
- def profiles():
- f = open ('./db.json', "r")
- data = json.loads(f.read())
- profiles.finalJSON = json.dumps(data, indent=2)
- f.close()
- print(profiles.finalJSON)
- def createPass():
- createPass.profileName = input("\nWhat profile would you want to save this to? (i.e. Minecraft Password): ")
- createPass.passLimit = int(input("How long do you want your password(s) to be: "))
- createPass.options = int(input("Options:\n"+"\t1. Just Letters \t2. Letters & Numbers \t3. Letters, Numbers & Punctuation: "))
- if(createPass.options == 1):
- createPass.randomChar = ''.join(random.sample(string.ascii_letters, k=createPass.passLimit))
- elif(createPass.options == 2):
- createPass.randomChar = ''.join(random.sample(string.ascii_letters + string.digits + string.octdigits, k=createPass.passLimit))
- elif(createPass.options == 3):
- createPass.randomChar = ''.join(random.sample(string.ascii_letters + string.punctuation + string.hexdigits + string.octdigits + string.digits, k=createPass.passLimit))
- def generated():
- console.print("\n:closed_lock_with_key: Password Generated! :closed_lock_with_key:", style="bold green")
- time.sleep(0.75)
- console.print("[red]Password: [/red]" + createPass.randomChar)
- answerSave = input("Do you want to save this info? ")
- if(answerSave == "yes"):
- db.insert({'profile': createPass.profileName, 'password': createPass.randomChar})
- console.print("[green]Password " + createPass.randomChar + " Saved! [/green]")
- def profileManage():
- answerManageOptions = input("Options:\n\t1. Delete All Profiles (irreversible): ")
- if(answerManageOptions == "1"):
- db.truncate()
- def start():
- answer = input("Options:\n\t1. Look at profiles/passwords\t2. Manage Profiles\t3. Create new profile/password: ")
- if(answer == "1"):
- profiles()
- time.sleep(0.5)
- input("Press enter to exit...")
- if(answer == "2"):
- profileManage()
- time.sleep(0.5)
- input("Press enter to exit...")
- if(answer == "3"):
- createPass()
- generated()
- time.sleep(1)
- answer = input("Do you want to create another password? ")
- if(answer == "yes"):
- createPass()
- generated()
- else:
- time.sleep(0.5)
- input("Press enter to exit...")
- start()
Advertisement
Add Comment
Please, Sign In to add comment