-
Notifications
You must be signed in to change notification settings - Fork 0
Home
hollali edited this page Sep 23, 2023
·
1 revision
Welcome to the Password_generator wiki! Creating a wiki page for the provided Python code:
This Python script generates random passwords of a specified length. It combines uppercase and lowercase letters, numbers, and special symbols to create a strong and random password.
- Run the Python script.
- Enter the desired length for the password when prompted.
- The script will generate a random password and display it.
- The script uses the
random
andstring
libraries to generate random characters. - The
LETTERS
variable contains all uppercase and lowercase letters. - The
NUMS
variable contains all digits from 0 to 9. - The
SPE
variable contains a set of special symbols. - The
Symbols
variable combines all the character sets. - The user is prompted to enter the desired password length.
- The script uses
random.sample()
to select random characters fromSymbols
based on the specified length. - The generated password is displayed on the screen.
import random
import string
LETTERS = string.ascii_letters
NUMS = '0123456789'
SPE = '-+*&$!_'
Symbols = LETTERS + NUMS + SPE
length = int(input("ENTER PASS. LENGTH"))
password = "".join(random.sample(Symbols, length))
print(password)
You can customize this script by:
- Adding or removing characters from the
LETTERS
,NUMS
, andSPE
variables to control the character set used for password generation. - Modifying the input prompt and output message for a better user experience.
- Implementing error handling to handle invalid input.
While this script generates random passwords, it is essential to use strong and unique passwords for different accounts and consider using a password manager to securely store and manage passwords.
This script is provided under the MIT License.