-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHWPasswordGenerator.py
More file actions
51 lines (38 loc) · 1.71 KB
/
HWPasswordGenerator.py
File metadata and controls
51 lines (38 loc) · 1.71 KB
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
# Task Advanced: Create a Password Generator for Linux Users
# Your task is to create a password generator program using Python specifically designed for Linux users.
# The program should generate strong and secure passwords that can be used for user accounts on Linux systems.
# Requirements:
# Prompt the user to enter the desired length for the password.
# Generate a random password consisting of a combination of uppercase letters, lowercase letters, numbers, and special characters.
# Ensure that the generated password meets the following criteria:
# Contains at least one uppercase letter
# Contains at least one lowercase letter
# Contains at least one number
# Contains at least one special character (e.g., !, @, #, $, %, etc.)
# Display the generated password to the user.
# Note:
# You can utilize the random module in Python to generate random characters and build the password.
# Consider using the string module in Python to access sets of characters (uppercase, lowercase, numbers, and special characters).
# Make sure to include clear instructions and error handling for invalid input.
import string
import random
print("Welcome to the Linux User Password Generator!")
upper = string.ascii_uppercase
lower = string.ascii_lowercase
number = string.digits
special = string.punctuation
allsymb = upper + lower + number + special
password = ""
length = int(input("Please enter the desired password length: "))
if upper:
allsymb += upper
if lower:
allsymb += lower
if number:
allsymb += number
if special:
allsymb += special
for x in range(length):
password = "".join(random.sample(allsymb, length))
print("Generated password: ", (password))
input()