Skip to content
Open
Show file tree
Hide file tree
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
38 changes: 38 additions & 0 deletions PasswordGenerator/PasswordGenerator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import random
import string

def generate_password(length=12):
"""
Generate a random secure password.

Parameters:
length (int): The length of the password (default is 12)

Returns:
str: Generated password or None if length < 6
"""
# Check if the requested password length is too short
if length < 6:
print("Password length should be at least 6 characters.")
return None

# Combine all possible characters: letters (uppercase + lowercase), digits, and punctuation
characters = string.ascii_letters + string.digits + string.punctuation

# Randomly select 'length' number of characters from the combined list
password = ''.join(random.choice(characters) for _ in range(length))

# Return the generated password
return password

# This part runs when the script is executed directly
if __name__ == "__main__":
# Ask the user to input the desired password length
length = int(input("Enter password length: "))

# Generate the password using the function
password = generate_password(length)

# If a password was successfully generated, print it
if password:
print("Generated password:", password)
16 changes: 16 additions & 0 deletions PasswordGenerator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# PasswordGenerator

## Description
This Python script generates a random, secure password.
It uses letters (uppercase & lowercase), numbers, and special characters to create strong passwords.

## How to Use
1. Run the script:

2. Enter the desired password length (minimum 6 characters).
3. The generated password will appear on the screen.

## Use Cases
- Quickly generate strong passwords for online accounts
- Create passwords for apps or software projects
- Improve personal cybersecurity by avoiding weak passwords