#!/usr/bin/env python3 from string import ( ascii_lowercase, ascii_uppercase, digits, punctuation ) from secrets import choice OPTIONS = {ascii_lowercase, ascii_uppercase, digits, punctuation} NUMBER_OF_CHARS = 64 current = None def next(): global current current = choice(tuple(OPTIONS - {current})) return choice(current) def genpass_fips(n=NUMBER_OF_CHARS): return ''.join(next() for i in range(0, n)) if __name__ == '__main__': pick_from = 4096 print(choice([genpass_fips() for i in range(0, pick_from)]))