Last active
July 4, 2021 18:05
-
-
Save beatorizu/6ebf6a97be28951ddcb38e9ef8cef334 to your computer and use it in GitHub Desktop.
A simple code to generate passwords
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
-r requirements.txt | |
autopep8 | |
flake8 |
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
# Reference https://stackoverflow.com/a/39596292/5298722 | |
import secrets | |
import string | |
import click | |
import pyperclip | |
@click.command() | |
@click.option('--lenght', '-l', default=8, help='The lenght of the password') | |
@click.option('--digits', '-d', default=False, help='Include digits [0-9]', is_flag=True) | |
@click.option('--punctuation', '-p', default=False, help='Include punctuation', is_flag=True) | |
def generate_password(lenght, digits, punctuation): | |
"""Simple code to generate passwords""" | |
chars = string.ascii_letters + string.digits * digits + string.punctuation * punctuation | |
password = ''.join(secrets.choice(chars) for _ in range(lenght)) | |
pyperclip.copy(password) | |
if __name__ == '__main__': | |
generate_password() |
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
click | |
pyperclip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment