Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # my discord is OnlyJoking#6197 go ahead and add me if you want
- import sys
- import random
- args = sys.argv[1:]
- helpMessage = "Please provide a low number and a high number for the length (Low number first, high number second), then say either true or false for special characters such as: $:/^#@ etc."
- low = ""
- high = ""
- special_chars = ""
- try:
- low = args[0]
- high = args[1]
- special_chars = args[2]
- except IndexError:
- print("\nInvalid arguments. "+helpMessage)
- sys.exit(0)
- try:
- low = int(low)
- high = int(high)
- if(special_chars.lower() == "true"): # kill me
- special_chars = bool(True)
- else: # anything else but true we'll just let the user slide with
- special_chars = bool(False)
- except ValueError:
- print("\nFailed to parse arguments. "+helpMessage)
- sys.exit(0)
- length = random.randint(low, high)
- characters = list("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789")
- if(special_chars):
- characters.append("!") # why can i not just have these all in a string then list() them? like really python? i did it with the characters
- characters.append("@") # like characters.append(list("!@#$%^&*:<>?")), that's it python.
- characters.append("#")
- characters.append("$")
- characters.append("%")
- characters.append("^")
- characters.append("&")
- characters.append("*")
- characters.append(":")
- characters.append("<")
- characters.append(">")
- characters.append("?")
- password = ""
- charAmount = 0
- while charAmount < length: # gen the password
- password += random.choice(characters)
- charAmount += 1
- print("\n"+password)
- # ARE YOU READY KIDS!?!? THIS IS WHERE THE CODE BECOME WORSE! I KNOW, YOU THOUGHT IT WAS IMPOSSIBLE.
- savePassword = ""
- def savePasswordFile():
- sys.stdout.write("\nWhat website is this account for? (The name not domain)\n")
- account = input().lower()
- sys.stdout.write("\nWhat is the username/email address for the account?\n")
- username = input().lower()
- passwordFile = open(account+" ("+username+").txt", "w")
- passwordFile.writelines("Hello, on the left side of the colon (this: ':') is the username/email,\nand on the right sideis the password that was generated.\n")
- passwordFile.writelines(username+":"+password)
- passwordFile.close()
- print("password saved!")
- sys.exit(0)
- def askToSave(repeat):
- sys.stdout.write("\nWould you like to save this password? (y/n)\n")
- if(repeat == True):
- savePassword = input().lower()
- if(savePassword == "y"): # using this two times but i'm too lazy to figure out how to put it into a function, if that's even possible
- savePasswordFile()
- elif(savePassword == "n"):
- sys.exit(0)
- else:
- print("Invalid choice!")
- askToSave(True)
- askToSave(False)
- savePassword = input().lower()
- if(savePassword == "y"):
- savePasswordFile()
- elif(savePassword == "n"):
- print("\nExiting...")
- sys.exit(0)
- else:
- print("\nInvalid choice!")
- askToSave(True)
- sys.exit(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement