Password Generator App

Password Generator App

Password Generator Apps.

Nowadays one of the reason why people are easily hack is because of the strength of their password. a very secure password should be of four combinations which are:

  1. capital letter
  2. Small letter
  3. numbers
  4. special characters

So our interest today is to create an app that will be generating password of specific length with the 4 properties listed above.

How to get Started.

Notice from the properties above we need Alphabet,numbers and all special character. the following step will be taken Step 1 : Declare some variables that will hold all properties needed code>>

passwordlength = int(input("enter the length of password"))
capLetters="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
smaLetters="abcdefghijklmnopqrstuvwxyz"
numbers='01234567890'
specialXter='!@#$%^&*()?'

Step 2: get the password length from the user by using input() function.

passwordlength = int(input("enter the length of password: "))

Step 3: now we need to select form each of the properties to form our password. we will select most of the password from small letter while we will select just one from the others. codes

import random
pswdCapLetters=random.sample(letters,1) #select one from the small letter
pswdSmaLetters=random.sample(letters,passwordlength-3) #select the length-3 from the small letters
passwordNumber=random.sample(numbers,1)#select one from the numbers
passwordXter=random.sample(specialXter,1)#select one from the special Character

Note: to import random here is very important as we need to be selecting at random.

Step4 : we need to marge all the password together to form a lonngPassword codes

 longPassword= ''.join(pswdSmaLetters +pswdCapLetters + passwordNumber + passwordXter)

step5: to print the password out

 print(longPassword)

the whole codes is below: Codes


capLetters="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
smaLetters="abcdefghijklmnopqrstuvwxyz"
numbers='01234567890'
specialXter='!@#$%^&*()?'
passwordlength = int(input("enter the length of password: "))
import random
pswdCapLetters=random.sample(capLetters,1) #select one from the small letter
pswdSmaLetters=random.sample(smaLetters,passwordlength-3) #select the length-3 from the small letters
passwordNumber=random.sample(numbers,1)#select one from the numbers
passwordXter=random.sample(specialXter,1)#select one from the special Character
longPassword= ''.join(pswdSmaLetters +pswdCapLetters + passwordNumber + passwordXter)
print(longPassword)

The following are the result after running the codes 4 times Results>>

enter the length of password: 8
qgemdW2&
enter the length of password: 5
fsA9&
enter the length of password: 9
xndqerM2$
enter the length of password: 8
wlgzjD1)

you can run and rerun again to see different password you will get as you provide the length. I hope you find this article helpful??. you can comment below or chat me up if you have any question or correction on 09153036869. Enjoy coding!