PASSWORD GENERATOR PYTHON BOT
PASSWORD GENERATOR BOT of PYTHON
import random
import string
def generate_password(length):
characters = string.ascii_letters + string.digits + string.punctuation
password = ''.join(random. Choice(characters) for _ in range(length))
return password
# Example usage to generate a 12-character password
password = generate_password(12)
print(password)
import string
def generate_password(length):
characters = string.ascii_letters + string.digits + string.punctuation
password = ''.join(random. Choice(characters) for _ in range(length))
return password
# Example usage to generate a 12-character password
password = generate_password(12)
print(password)
YOU CAN ALSO USE THIS ONE
import random
import string
def generate_password(length, uppercase, lowercase, numbers, special):
# Generates a password with customizable options for length, complexity, and character types.
# Define the character sets for each type of character
character_sets = []
if uppercase:
character_sets.append(string.ascii_uppercase)
if lowercase:
character_sets.append(string.ascii_lowercase)
if numbers:
character_sets.append(string.digits)
if special:
character_sets.append(string.punctuation)
# Ensure the length of the password is at least 8 characters
length = max(length, 8)
# Combine the character sets into a single pool of possible characters
possible_chars = ''.join(character_sets)
# Generate the password
password = ''.join(random.choice(possible_chars) for _ in range(length))
# Save the password to a file
with open("password.txt", "a") as f:
f.write(password + '\n')
return password
# Example usage
password = generate_password(length=12, uppercase=True, lowercase=True, numbers=True, special=True)
print(password)
Comments
Post a Comment