Skip to content

Instantly share code, notes, and snippets.

@daxxog
Created July 8, 2021 14:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daxxog/0c79954a794abcfdd93b1db1c40fe6b8 to your computer and use it in GitHub Desktop.
Save daxxog/0c79954a794abcfdd93b1db1c40fe6b8 to your computer and use it in GitHub Desktop.
Generate a FIPS Compliant secure password
#!/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)]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment