Random Password Generator using Python

  • Our password is very important for you and us. 
  • Choosing passwords for accounts can sometimes be boring. 
  • So, let's solve this problem in a pythonic way and know how it happens. 
  • Let's create our own password generator using Python and avoid hackers yourself.

First Our Goal

  • We need a correctly secured password. 
  • So, our password contains digit, symbol lowercase and uppercase alphabet. 
  • So, first we ask users how long is your password because we are safe or not.

Project Requirement

To build this project we will use the basic concept of python and libraries –  random, string.

Installation

  • We are used these two models, random and string
  • In case not installed then copy this following command and paste in your terminal/CMD (Command Prompt) to install.
  • These are two way using sudo command and without using sudo.

pip install string

sudo pip install string

pip install ramdom

sudo pip install random

The First step is to import libraries

import string 
import random


Password.py

import string
import random
if __name__ == "__main__":
    m1 = string.ascii_lowercase
    m2 = string.ascii_uppercase
    m3 = string.digits
    m4 = string.punctuation
    plentxt = int(input("Enter Your Password Length: "))
    m = []
    m.extend(list(m1))
    m.extend(list(m2))
    m.extend(list(m3))
    m.extend(list(m4))
    print("Your password is: ", end="")
    print("".join(random.sample(m, plentxt)))

OUTPUT

  Enter Your Password Length: 8
  Your password is: |&`_afI