def getpassword(question, argsgiven=None, width=_defaultwidth, echo=False, reader=getpass.getpass, numerics=False, leetify=False, symbols=False, special_signs=False, length=None): # pragma: no cover # TODO: getpassword should recieve a config insatnce # and generate the policy according to it, # so that getpassword in cli would be simplified if argsgiven == 1 or length: while not length: try: length = getinput("Password length (default 7): ", default='7') length = int(length) except ValueError: print("please enter a proper integer") password, dumpme = generator.generate_password(length, length, True, leetify, numerics, special_signs) print ("New password: %s" % (password)) return password # no args given while True: a1 = reader(question.ljust(width)) if not a1: return getpassword('', argsgiven=1) a2 = reader("[Repeat] %s" % (question.ljust(width))) if a1 == a2: if leetify: return generator.leetify(a1) else: return a1 else: print ("Passwords don't match. Try again.")
def get_password(self, argsgiven, numerics=False, leetify=False, symbols=False, special_signs=False): """ in the config file: numerics -> numerics leetify -> symbols special_chars -> special_signs """ if argsgiven == 1: length = tools.getinput("Password length (default 7): ", "7") length = int(length) password, dumpme = generator.generate_password(length, length, True, leetify, numerics, special_signs) print "New password: %s" % (password) return password # no args given password = tools.getpassword("Password (Blank to generate): ", tools._defaultwidth, False) if len(password) == 0: length = tools.getinput("Password length (default 7): ", "7") length = int(length) (password, dumpme) = generator.generate_password(length, length, True, leetify, numerics, special_signs) print "New password: %s" % (password) return password
def get_password(self, default=""): password = getpassword("Password (Blank to generate): ", _defaultwidth, False) if len(password) == 0: length = getinput("Password length (default 7): ", "7") length = int(length) numerics = config.get_value("Generator", "numerics") == 'true'; leetify = config.get_value("Generator", "leetify") == 'true'; (password, dumpme) = generator.generate_password(length, length, True, leetify, numerics) print "New password: %s" % (password) return password else: return password
def get_password(self, default=""): password = getpassword("Password (Blank to generate): ", _defaultwidth, False) if len(password) == 0: length = getinput("Password length (default 7): ", "7") length = int(length) numerics = config.get_value("Generator", "numerics") == 'true' leetify = config.get_value("Generator", "leetify") == 'true' (password, dumpme) = generator.generate_password(length, length, True, leetify, numerics) print "New password: %s" % (password) return password else: return password