Skip to content

Instantly share code, notes, and snippets.

@graydenshand
Created July 27, 2023 02:10
Show Gist options
  • Save graydenshand/96353d17e97a103f5035e14be2591a01 to your computer and use it in GitHub Desktop.
Save graydenshand/96353d17e97a103f5035e14be2591a01 to your computer and use it in GitHub Desktop.
import argparse
import secrets
import string
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-s", "--symbols", help="Include symbols in password", action="store_true")
parser.add_argument("-l", "--length", type=int, default=16, help="Password length")
args = parser.parse_args()
alphabet = string.ascii_letters + string.digits
if args.symbols:
alphabet += string.punctuation
print(''.join(secrets.choice(alphabet) for _ in range(args.length)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment