Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions Python Projects/random_pass_generator/Password_generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

import random
import string

def generate_random_password(length, use_uppercase, use_digits, use_special_chars):
characters = string.ascii_lowercase
if use_uppercase:
characters += string.ascii_uppercase
if use_digits:
characters += string.digits
if use_special_chars:
characters += string.punctuation

if length < 8:
print("Password length is too short. It should be at least 8 characters.")
return

password = ''.join(random.choice(characters) for _ in range(length))
return password

# User preferences
password_length = int(input("Enter the desired password length: "))
include_uppercase = input("Include uppercase letters? (yes/no): ").lower() == "yes"
include_digits = input("Include digits? (yes/no): ").lower() == "yes"
include_special_chars = input("Include special characters? (yes/no): ").lower() == "yes"

password = generate_random_password(password_length, include_uppercase, include_digits, include_special_chars)

if password:
print("Generated Password: ", password)