-
Notifications
You must be signed in to change notification settings - Fork 0
/
pwdgen.py
60 lines (50 loc) · 1.58 KB
/
pwdgen.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import argparse
from generator import pwdgen
import pyperclip
parser = argparse.ArgumentParser(
description="""Simple password generator in Python. If nothing is being entered, the script will automatically create a strong password."""
)
parser.add_argument(
"-s",
"--strength",
default="strong",
type=str,
help="To create a strong password, enter 'strong'. To create a weak password, enter 'weak'",
)
"""
parser.add_argument(
"-hd",
"--hidden",
default = 0,
type=str,
help="If you do not want the password to print to the command line interface, use -h",
)
"""
parser.add_argument(
"-c",
"--copy",
type=str,
help="Copies the password directly into your clipboard. Disabled by default",
)
args = parser.parse_args()
def generate(args):
"""Generating passwords based on user input. By default, strong passwords are generated.
Parameters:
args (str): Depending on user entry, either "weak" or "strong"
Returns:
pwd (str): Returns a password generated by pwdgen(*) with either "strong" or "weak" as parameter.
"""
if args.strength.lower() == "strong":
return pwdgen("strong")
elif args.strength.lower() == "weak":
return pwdgen("weak")
else:
print("Enter 'weak' or 'strong', please!")
if __name__ == "__main__":
pwd = generate(args)
print(f"Password generated: {pwd}")
print("Copying password to clipboard...")
if pyperclip.copy(pwd) == None:
print(
"Password successfully copied to clipboard.\nUse CTRL+V to paste password!"
)