Skip to content

Commit 8ecb7aa

Browse files
authored
Merge pull request #336 from cronousz/main
addded file random-password-generator using python programs
2 parents 4078b87 + 2976870 commit 8ecb7aa

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
import random
3+
import string
4+
5+
def generate_random_password(length, use_uppercase, use_digits, use_special_chars):
6+
characters = string.ascii_lowercase
7+
if use_uppercase:
8+
characters += string.ascii_uppercase
9+
if use_digits:
10+
characters += string.digits
11+
if use_special_chars:
12+
characters += string.punctuation
13+
14+
if length < 8:
15+
print("Password length is too short. It should be at least 8 characters.")
16+
return
17+
18+
password = ''.join(random.choice(characters) for _ in range(length))
19+
return password
20+
21+
# User preferences
22+
password_length = int(input("Enter the desired password length: "))
23+
include_uppercase = input("Include uppercase letters? (yes/no): ").lower() == "yes"
24+
include_digits = input("Include digits? (yes/no): ").lower() == "yes"
25+
include_special_chars = input("Include special characters? (yes/no): ").lower() == "yes"
26+
27+
password = generate_random_password(password_length, include_uppercase, include_digits, include_special_chars)
28+
29+
if password:
30+
print("Generated Password: ", password)
31+
32+

0 commit comments

Comments
 (0)