Skip to content
hollali edited this page Sep 23, 2023 · 1 revision

Welcome to the Password_generator wiki! Creating a wiki page for the provided Python code:

Random Password Generator

Overview

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.

Usage

  1. Run the Python script.
  2. Enter the desired length for the password when prompted.
  3. The script will generate a random password and display it.

Code Explanation

  • The script uses the random and string 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 from Symbols based on the specified length.
  • The generated password is displayed on the screen.

Example

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)

Customization

You can customize this script by:

  • Adding or removing characters from the LETTERS, NUMS, and SPE 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.

Security Note

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.

License

This script is provided under the MIT License.

Clone this wiki locally