Coders Packet

Password Generator in Python

By Deepanshu Mittal

Python program to generate Password of User's desired length and desired types of ASCII characters in it.

The program generates a Random Password according to user's requirements using Python 3.6 programming language. Program takes input from the user for the desired length of the password and the types of characters user needs in the password.

This Python program uses two libraries: 'random' and 'string'.

The 'random' library is used to generate random characters from the collections of all characters of its type using 'randrange()' function of 'random' module.

The 'string' library is used to create containers for containing all characters of all four types: lower case alphabets (a to z) by 'ascii_lowercase' functionality, upper case alphabets (A to Z) by 'ascii_uppercase' functionality, numbers from (0 to 9) by 'digits' functionality and symbols (like: ?,/,[,},#,$,%,^,&,*,etc.) by 'puctuation' functionality, of 'string' module.

Finally the program prints the password generated of the user's specified length built using specified types of characters.

For example, let the length be 10 and types of characters allowed be only lower case alphabets (a to z).

Moreover, different combinations of different types of characters can be used to generate password.

So, here the password is generated of length 20 and contains upper case alphabets (A to Z), lower case alphabets (a to z) and symbols (like: ?,/,[,},#,$,%,^,&,*,etc.).

Download Complete Code

Comments

No comments yet