-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPasswordGenerator.py
More file actions
21 lines (17 loc) · 1.01 KB
/
PasswordGenerator.py
File metadata and controls
21 lines (17 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Generate a Password with secrets and string libraries in Python
# -------------------------------------------------------------------------------------------------------------------------------
# This script generates a random password using the secrets and string libraries in Python.
# It creates a password that includes letters, digits, and punctuation characters.
# Note: The function is executed immediately upon definition.
# -------------------------------------------------------------------------------------------------------------------------------
# Importing necessary libraries
import secrets
import string
# This function generates a random password of a specified length.
def generate_password(length=12):
alphabet = (string.ascii_letters + string.digits + string.punctuation)
return ''.join(secrets.choice(alphabet) for _ in range(length))
# Immediately Invoked Function Expression (IIFE)
password = generate_password()
# Print the generated password
print(f"Your new Generated Password: {password}")