Mercurial > hg > config
comparison python/generate_password.py @ 871:1b6f0650dabb
add script to generate passwords
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Tue, 07 May 2019 10:34:38 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
870:ff31f0975d71 | 871:1b6f0650dabb |
---|---|
1 #!/usr/bin/env python | |
2 | |
3 import random | |
4 import string | |
5 import sys | |
6 | |
7 pool = ''.join([string.ascii_letters, | |
8 string.digits, | |
9 string.punctuation]) | |
10 | |
11 contents = [(string.ascii_lowercase, 6), | |
12 (string.ascii_uppercase, 6), | |
13 (string.punctuation, 2)] | |
14 | |
15 def password(length=16, pool=pool): | |
16 return ''.join(random.sample(pool, length)) | |
17 | |
18 def main(args=sys.argv[1:]): | |
19 """CLI""" | |
20 | |
21 print(password()) | |
22 | |
23 if __name__ == '__main__': | |
24 main() |