-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpasswordgenerator.py
More file actions
26 lines (19 loc) · 892 Bytes
/
Copy pathpasswordgenerator.py
File metadata and controls
26 lines (19 loc) · 892 Bytes
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
import random
import string
def generate_password(length, complexity):
if complexity == "low":
characters = string.ascii_letters + string.digits
elif complexity == "medium":
characters = string.ascii_letters + string.digits + string.punctuation
elif complexity == "high":
characters = string.ascii_letters + string.digits + string.punctuation + string.ascii_letters.upper() + string.punctuation
password = ''.join(random.choice(characters) for _ in range(length))
return password
def main():
print("Welcome to the Password Generator!")
length = int(input("Enter the desired length of the password: "))
complexity = input("Enter the complexity (low, medium, high): ")
password = generate_password(length, complexity)
print(f"\nGenerated Password: {password}")
if __name__ == "__main__":
main()