Add --quiet option, only output the generated passwords.
This commit is contained in:
parent
6795454af1
commit
4596fc38ee
29
bin/pwgen
29
bin/pwgen
@ -10,6 +10,10 @@ default_config_file=os.path.expanduser('~/.pwgen.cfg')
|
|||||||
def main():
|
def main():
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Generate passwords')
|
parser = argparse.ArgumentParser(description='Generate passwords')
|
||||||
|
parser.add_argument(
|
||||||
|
'--quiet', '-q',
|
||||||
|
action='store_true',
|
||||||
|
help='Only echo the generated passwords.')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--generate-config', '-g',
|
'--generate-config', '-g',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
@ -82,6 +86,9 @@ def main():
|
|||||||
|
|
||||||
args = vars(parser.parse_args())
|
args = vars(parser.parse_args())
|
||||||
|
|
||||||
|
quiet = args['quiet']
|
||||||
|
del args['quiet']
|
||||||
|
|
||||||
config_file = args['config_file']
|
config_file = args['config_file']
|
||||||
del args['config_file']
|
del args['config_file']
|
||||||
|
|
||||||
@ -103,16 +110,20 @@ def main():
|
|||||||
|
|
||||||
pwds, seen_entropy = pwgen.generate_passwords(conf)
|
pwds, seen_entropy = pwgen.generate_passwords(conf)
|
||||||
|
|
||||||
print("Generated {} passwords".format(len(pwds)))
|
if (quiet):
|
||||||
if seen_entropy:
|
for pw in pwds.keys():
|
||||||
print("Full-knowledge entropy is {0:.2g}".format(seen_entropy))
|
print(pw)
|
||||||
else:
|
else:
|
||||||
print("Unable to calculate full-knowledge entropy since max_length is used")
|
print("Generated {} passwords".format(len(pwds)))
|
||||||
print("Blind entropy\tPassword")
|
if seen_entropy:
|
||||||
print("========================")
|
print("Full-knowledge entropy is {0:.2g}".format(seen_entropy))
|
||||||
for pw in pwds.keys():
|
else:
|
||||||
print("{:.5n}\t\t{}".format(pwds[pw]['entropy'], pw))
|
print("Unable to calculate full-knowledge entropy since max_length is used")
|
||||||
print("========================")
|
print("Blind entropy\tPassword")
|
||||||
|
print("========================")
|
||||||
|
for pw in pwds.keys():
|
||||||
|
print("{:.5n}\t\t{}".format(pwds[pw]['entropy'], pw))
|
||||||
|
print("========================")
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user