PWP Mic
PWP Mic
INTRODUCTION
we will build a Random Password Generator in Python. The "Random Password Generator" is a
program that will generate strong random passwords of the specified length with the help of the
alphabet, numbers, and symbols. Let us first understand the prerequisites and build the intuition
of the program so that the implementation can become simpler.
But before we start, a good knowledge of Python programming language is necessary, along with
a clear understanding of the random module and data structures to build a random password
generator in Python.
Passwords are a means by which a user proves that they are authorized to use a device. It is
important that passwords must be long and complex. It should contain at least more than ten
characters with a combination of characters such as percent (%), commas(,), and parentheses,
as well as lower-case and upper-case alphabets and numbers. Here we will create a random
password using Python code.
EXAMPLE:-
import random
def generate_password(len):
"This function accepts a parameter 'len' and returns a randomly generated password"
list_of_chars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!@#$%^
&*()"
pass_str = ""
for i in range(len):
return pass_str
if __name__ == "__main__":
len = 8
pass_str = generate_password(len)
Output:-
Updating the Program to accept the Password Length from the User:-
Now that we have defined the function, we need to generate a password of a given length, it is
time for us to make one adjustment to the program. As observed in the previous program, we
have explicitly added the length of the required password. We can also accept the user's
password length by using the input() method in Python.
Let us consider the following snippet of code illustrating the same.
EXAMPLE :-
import random
def generate_password(len):
"This function accepts a parameter 'len' and returns a randomly generated password"
list_of_chars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!@#$%^
&*()"
pass_str = "".join(selected_char)
return pass_str
if __name__ == "__main__":
pass_str = generate_password(len)
Output:-
EXAMPLE :-
import random
def generate_password(len):
"This function accepts a parameter 'len' and returns a randomly generated password"
list_of_chars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!@#$%^
&*()"
pass_str = "".join(selected_char)
return pass_str
if __name__ == "__main__":
while True:
break
pass_str = generate_password(len)
print("")
else:
print("")
Output:-
CONCLUSION
o The Random Password Generator is a program that is able to generate strong random
passwords of the specified length with the combination of alphabets, numbers, and
symbols.
o In this tutorial, we have learned different ways of developing the Random Password
Generator using Python as the programming language.
o We have also observed the use of the Tkinter module to create a Graphical User Interface
(GUI) for the Random Password Generator.
o At last, we have discussed the reason for creating the Random Password Generator and
how strong passwords can be generated using this application.
REFERENCE
https://www.javatpoint.com/java-password-generator
https://www.javatpoint.com/random-password-generator-in-python
https://www.dashlane.com/features/password-generator