Skip to content

Injamul2k24/Password_Generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 

Repository files navigation

Random Password Generator

This is a simple Python script to generate random passwords based on user preferences. The script allows you to specify the length of the password and whether to include special characters and numbers.

Features

Customizable Length: Specify the desired length of your password. Special Characters: Choose whether to include special characters. Numbers: Choose whether to include numbers. Simple and Easy to Use: User-friendly input prompts to guide you through the process.
Usage
1. Clone the repository:
git clone https://github.com/injamul2k24/password_generator.git
  1. Navigate to the project directory:

    cd password_generator
  2. Run the script:

    python password_generator.py
  3. Follow the prompts to generate your password.

Example
$ python password_generator.py
How long password do you want to generate? 12
Include special characters? Yes/No: Yes
Include numbers? Yes/No: Yes

Generated Password: aB!9zL@3xN2p
Code

Here is the code for the password generator:

import random

string_char = 'abcdefghijklmnopqrstuvwxyz'
string_num = '0123456789'
special_char = '~!@#$%^&*()'

def GeneratePassword(length, use_special_chars, use_numbers):
  """Generates a random password based on user preferences."""
  password = ''
  
  for _ in range(length-2):
      password += random.choice(string_char)
      
  if use_numbers:
      password += random.choice(string_num)
  else:
      password += random.choice(string_char)

  if use_special_chars:
      password += random.choice(special_char)
  else:
      password += random.choice(string_char)

  return password

length = int(input("How long password do you want to generate? "))
use_special_chars = input("Include special characters? Yes/No: ").lower() == 'yes'
use_numbers = input("Include numbers? Yes/No: ").lower() == 'yes'

generated_password = GeneratePassword(length, use_special_chars, use_numbers)
print("\nGenerated Password:", generated_password)

Feel free to contribute to this project by making suggestions or adding new features. Your feedback is welcome!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages