Today world is internet world. Most of the people uses internet to transfer their data on communication network. So data should be safe from unauthorized user. Unauthorized user can theft our data and misuse it. Only strong passwords stop other people from accessing our computers,personal emails and website login details. In this project,we will build a strong password picker tool that make secure,memorable passwords to help keep our information safe. An unusual password made up of several different parts will help protect against crackers and intruders. We will create good password by using this password picker tool. A good password is easy to remember but hard for a person or intruder to guess.
How it works
Password picker is a Random Password generating program which generates a strong passwords by combining words,numbers,characters. The password picker program uses random choices from group of word, number,character,punctuation characters to assembles each password. When we run the program , it will create new password and show it on the screen. If you are not satisfied with the password,then you can ask it to keep creating new passwords until you find one you like.
Module used
- random module : random module helps to make random choices
- string module : The string module help us to do useful things with strings,like splitting them apart or changing the way they appear
How to code
In order to access the Python library, we need to import the package in our Python script.
import random import string
We will need list of words to create new passwords. In python ,we can keep a group of things together as a list. So in this project we will make two different list of words. First we will create the variable text1 and text2 to store list of different words and separate each item with a comma.
text1 = ['Python','c#','java','oracle','sql', 'orchid','active','tiny','Green', 'purple','Ada','Nikon','nivea'] text2 = ['project','pista','lIttle', 'bAll','SCripts','Code','Idea', 'Hammer','bulb','Panda']
To create password, we will need to pick a random strings or words. we can do this using choice() function from random module. It will choose word randomly from string list and store that word in variable text3 and text4.
text3 = random.choice(text1) text4 = random.choice(text2)
Then we will use randrange() function from random module to select a random number from 0 to 99.
num = random.randrange(0,100)
We will use random.choice function to pick random punctuation character. This will make our password even harder to crack
special_char = random.choice(string.punctuation)
Now, we will assemble all the different parts to create more secure and strong password.
password = text3 + text4 + str(num) + special_char
Complete python code to generate password picker
import random
import string
text1 = ['Python','c#','java','oracle','sql',
'orchid','active','tiny','Green',
'purple','Ada','Nikon','nivea']
text2 = ['project','pista','lIttle',
'bAll','SCripts','Code','Idea',
'Hammer','bulb','Panda']
print(" *********** Password Checker *************")
while True :
text3 = random.choice(text1)
text4 = random.choice(text2)
num = random.randrange(0,100)
special_char = random.choice(string.punctuation)
password = text3 + text4 + str(num) + special_char
print(" Your new password is : %s" %password)
query = input("Would you like another password? Type y or n:")
if query =='n':
break
We can use while loopp to generate another password if the user says they want a different password.
Output
*********** Password Checker ************* Your new password is : GreenPanda39, Would you like another password? Type y or n:y Your new password is : Nikonproject23_ Would you like another password? Type y or n:y Your new password is : niveaproject9] Would you like another password? Type y or n:y Your new password is : orchidbulb83@ Would you like another password? Type y or n:y Your new password is : Adapista84) Would you like another password? Type y or n:y Your new password is : sqlSCripts66# Would you like another password? Type y or n:n
