Skip to content

Commit 386ad6e

Browse files
author
Sean Sweeney
committed
adding a new password generator project that creates passwords from user selection from the command line
1 parent 48fb214 commit 386ad6e

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

Password_Generator_2/README.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Secure Password Generator
2+
3+
This Python-based CLI tool generates a secure password based on user preferences.
4+
5+
## Features
6+
7+
- Customizable password length
8+
- Option to include uppercase, lowercase, numbers, and special symbols
9+
10+
## Installation
11+
12+
Ensure you have Python installed on your system.
13+
14+
## Usage
15+
16+
Run the script with Python and pass the necessary arguments:
17+
18+
```bash
19+
python main.py --length 16 --use_uppercase --use_lowercase --use_numbers --use_symbols

Password_Generator_2/main.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import argparse
2+
from password_generator import generate_password
3+
4+
def main():
5+
parser = argparse.ArgumentParser(description='Generate a secure password')
6+
parser.add_argument('-l', '--length', type=int, default=12, help='Length of the password')
7+
parser.add_argument('-u', '--use_uppercase', action='store_true', default=True, help='Include uppercase letters')
8+
parser.add_argument('-lc', '--use_lowercase', action='store_true', default=True, help='Include lowercase letters')
9+
parser.add_argument('-n', '--use_numbers', action='store_true', default=True, help='Include numbers')
10+
parser.add_argument('-s', '--use_symbols', action='store_true', default=True, help='Include special symbols')
11+
12+
args = parser.parse_args()
13+
14+
password = generate_password(args.length, args.use_uppercase, args.use_lowercase, args.use_numbers, args.use_symbols)
15+
print(f'Generated Password: {password}')
16+
17+
if __name__ == '__main__':
18+
main()
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import secrets
2+
import string
3+
4+
def generate_password(length, use_uppercase, use_lowercase, use_numbers, use_symbols):
5+
characters = ''
6+
if use_uppercase:
7+
characters += string.ascii_uppercase
8+
if use_lowercase:
9+
characters += string.ascii_lowercase
10+
if use_numbers:
11+
characters += string.digits
12+
if use_symbols:
13+
characters += string.punctuation
14+
15+
if not characters:
16+
raise ValueError("No character types selected for password generation")
17+
18+
password = ''.join(secrets.choice(characters) for i in range(length))
19+
return password

0 commit comments

Comments
 (0)