Last active
May 29, 2023 19:30
-
-
Save renegarcia/2ba8eebc987ee99c2c4ce5ff2ee75081 to your computer and use it in GitHub Desktop.
passgen.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from secrets import choice | |
import string | |
import argparse | |
ALPHABET = string.ascii_letters + string.digits + string.punctuation | |
def password_generator(len:int =10, alphabet: list[str] = ALPHABET) -> str: | |
return "".join(choice(alphabet) for i in range(len)) | |
def main(): | |
parser = argparse.ArgumentParser(description='Prints a random password.') | |
parser.add_argument('--len', type=int, default=10, help='Password length (default 10)') | |
args = parser.parse_args() | |
len = args.len | |
password = password_generator(len=len) | |
print(password) | |
if __name__ == '__main__': | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment