view python/generate_password.py @ 906:c70f4644c2aa

update for ubuntu 22.04
author Jeff Hammel <k0scist@gmail.com>
date Thu, 11 Apr 2024 08:31:15 -0700
parents 1b6f0650dabb
children
line wrap: on
line source

#!/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()