changeset 871:1b6f0650dabb

add script to generate passwords
author Jeff Hammel <k0scist@gmail.com>
date Tue, 07 May 2019 10:34:38 -0700
parents ff31f0975d71
children 633487219ed6
files python/generate_password.py
diffstat 1 files changed, 24 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/python/generate_password.py	Tue May 07 10:34:38 2019 -0700
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+
+import random
+import string
+import sys
+
+pool = ''.join([string.ascii_letters,
+                string.digits,
+                string.punctuation])
+
+contents = [(string.ascii_lowercase, 6),
+            (string.ascii_uppercase, 6),
+            (string.punctuation, 2)]
+
+def password(length=16, pool=pool):
+    return ''.join(random.sample(pool, length))
+
+def main(args=sys.argv[1:]):
+    """CLI"""
+
+    print(password())
+    
+if __name__ == '__main__':
+    main()