Report Final
Report Final
Report Final
A
Project Report
On
Bachelor of Technology
In
Computer Science & Engineering
Submitted by
ZAID NAWAZ (1902250100159)
Dec,2021
Downloaded by Cp S ([email protected])
lOMoARcPSD|26093351
Contents
DECLARATION III
CERTIFICATE IV
ACKNOWLEDGEMENT V
ABSTRACT VI
CHAPTER 1 (INTRODUCTION)
CHAPTER 3 (OBJECTIVE)
CHAPTER 7 (IMPLEMENTATION)
CHAPTER 8 (TESTING)
CONCLUSION
BIBLIOGRAPHY
Downloaded by Cp S ([email protected])
lOMoARcPSD|26093351
DECLARATION
I hereby declare that this submission is our own work and that to the best of our knowledge
and beliefs. It contains no material l previously published or written by neither any person
nor material which to a substant till extent has been accepted for the award of any other
degree or diploma of the university or other institute of higher learning , except here due
acknowledgement has been made in the text.
Signature:
Name: Nikhil Kumar
Roll No:190220100091
Date: 06/12/2021
Signature:
Name: Varun Upadhyay
Signature:
Name: Zaid Nawaz
RollNo.:1902250100159
Date: 06/12/2021
Downloaded by Cp S ([email protected])
lOMoARcPSD|26093351
CERTIFICATE
This is to certify that Project report entitled “Random Password Generator Using
Python”, Submitted by “NIKHIL KUMAR , ZAID NAWAZ and VARUN UPADHYAY”
for partial fulfillment of the requirement for the award of degree Bachelors of Technology in
Department of Computer Science & Engineering of Dr. A.P.J Abdul Kalam University,
Lucknow is a record of the candidate’s own work carried out by them under my supervision.
The matter embodied in this report is original and has not been submitted for the award of
any other degree.
Date: Supervisor
06/12/2021 Mr. Ashish Jain
Downloaded by Cp S ([email protected])
lOMoARcPSD|26093351
ACKNOWLEDGEMENT
In completing this project we have been fortunate enough to have help, support and
encouragement from many people. I would like to acknowledge them for their cooperation.
Firstly, we would like to thank Mr. Ashish Jain, from Department of Computer Science &
Engineering, A.I.M.T; for guiding us through each and every step of the process with
knowledge and support. His thoughts have been a constant source of inspiration for us.
We would also like to acknowledge the contribution of all faculty members of the department
for their kind assistance, suggestions and cooperation throughout the development of the
project.
Finally, we would like to thank our classmates for the encouragement and help during the
project.
Signature:
Name: Nikhil Kumar
Roll No:190220100091
Date: 06/12/2021
Signature:
Name: Varun Upadhyay
Roll No.:1902250100151
Date:06 /12/2021
Signature:
Name: Zaid Nawaz
RollNo.:1902250100159
Date: 06/12/2021
Downloaded by Cp S ([email protected])
lOMoARcPSD|26093351
ABSTRACT
A random password generator is software program or hardware device that takes input from
a random or pseudo-random number generator and automatically generates a password. Random
passwords can be generated manually, using simple sources of randomness such as dice or coins, or
they can be generated using a computer.
Speaking regarding the system, the user can create a random password according to various sizes. It
additionally presents with an aesthetic color-coded system which indicates the stamina of the
password, beginning from Very Weak to Superb password strength. After creating a random
password, the system presents it in the clipboard where the user can copy and paste easily.
This GUI based Password Generator supplies the most basic method for generating a solid
password for the individuals. In short, this job just concentrates on producing arbitrary passwords.
In order to run the task, you must have set up Python, on your PC. This is a basic GUI Based system,
specially composed for the beginners. Password Generator in Python with source code is
complementary to download. Use for education purpose only! For the project demo, look at the
picture slider listed below.
Downloaded by Cp S ([email protected])
lOMoARcPSD|26093351
1. INTRODUCTION
With growing technology, everything has relied on data and securing these data is the main
concern. Passwords are meant to keep the data safe that we upload on the Internet.
An easy password can be hacked easily and all the personal information can be misused. In order
to prevent such things and keep the data safe, it is quite necessary to keep our passwords very
strong.
A password generator is a software application device that creates arbitrary or tailored passwords for
individuals. It assists individuals to produce more powerful passwords that offer greater protection
for a provided sort of access. Some password generators are merely random password generators.
These programs produce complex/strong passwords with mixes of numbers, uppercase and also
lowercase letters, and also unique personalities such as dental braces, asterisks, slashes, and so on.
It is a tool that generates passwords based on the given guidelines that you set to create an
unpredictable strong password for your accounts.
The Password generator tool creates a random and customized password for users that helps them to
create a strong password which provides greater security. While there are many examples of
"random" password generator programs available on the Internet, generating randomness can be
tricky and many programs do not generate random characters in a way that ensures strong security. A
common recommendation is to use open source security tools where possible since they allow
independent checks on the quality of the methods used. Note that simply generating a password at
random does not ensure the password is a strong password, because it is possible, although highly
unlikely, to generate an easily guessed or cracked password. In fact, there is no need at all for a
password to have been produced by a perfectly random process: it just needs to be sufficiently
difficult to guess.
A password generator can be part of a password manager. When a password policy enforces complex
rules, it can be easier to use a password generator based on that set of rules than to manually create
passwords.
Downloaded by Cp S ([email protected])
lOMoARcPSD|26093351
2. PROJECT OVERVIEW
Speaking regarding the system, the user can create a random password according to various sizes.
It additionally presents with an aesthetic color-coded system which indicates the stamina of the
password, beginning from Very Weak to Superb password strength. After creating a random
password, the system presents it in the clipboard where the user can copy and paste easily.
This GUI based Password Generator supplies the most basic method for generating a solid password
for the individuals. In short, this job just concentrates on producing arbitrary passwords. In order to
run the task, you must have set up Python, on your PC. This is a basic GUI Based system, specially
composed for the beginners. Password Generator in Python with source code is complementary to
download. Use for education purpose only! For the project demo, look at the picture slider listed
below.
Downloaded by Cp S ([email protected])
lOMoARcPSD|26093351
3. STRONGER METHODS
A variety of methods exist for generating strong, cryptographically secure random passwords.
On Unix platforms /dev/random and /dev/urandom are commonly used, either programmatically or
in conjunction with a program such as makepasswd. Windows programmers can use
the Cryptographic Application Programming Interface function CryptGenRandom. The Java
programming language includes a class called SecureRandom. Another possibility is to derive
randomness by measuring some external phenomenon, such as timing user keyboard input.
Many computer systems already have an application (typically named "apg") to implement FIPS
181. FIPS 181—Automated Password Generator—describes a standard process for converting
random bits (from a hardware random number generator) into somewhat pronounceable "words"
suitable for a passphrase. However, in 1994 an attack on the FIPS 181 algorithm was discovered,
such that an attacker can expect, on average, to break into 1% of accounts that have passwords based
on the algorithm, after searching just 1.6 million passwords. This is due to the non-uniformity in the
distribution of passwords generated, which can be addressed by using longer passwords or by
modifying the algorithm.
Bash
Here is a code sample that uses /dev/urandom to generate a password with a simple Bash function.
This function takes password length as a parameter, or uses 16 by default:
function mkpw() { LC_ALL=C tr -dc '[:graph:]' < /dev/urandom | head -c ${1:-16}; echo; }
Java
Here is a code sample (adapted from the class PasswordGenerator[12]) that uses SecureRandom to
generate a 10 hexadecimal character password:
String[] symbols = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"};
int length = 10;
Random random = SecureRandom.getInstanceStrong(); // as of JDK 8, this should return the
strongest algorithm available to the JVM
StringBuilder sb = new StringBuilder(length);
Downloaded by Cp S ([email protected])
lOMoARcPSD|26093351
TypeScript
JavaScript
This example uses the Web Crypto API to generate cryptographically secure random numbers
uniformly.
function secureRandom(count) {
let num = 0
const crypto = window.crypto || window.msCrypto
const min = 2 ** 32 % count
Downloaded by Cp S ([email protected])
lOMoARcPSD|26093351
do {
num = crypto.getRandomValues(rand)[0]
} while (num < min)
return password
}
Perl
This example uses the Crypt::Random:: Source module to find a source of strong random numbers
(which is platform dependent).
Downloaded by Cp S ([email protected])
lOMoARcPSD|26093351
$out .= $a;
}
print $out;
Python
Until version 3.5.10, the random module includes a SystemRandom class that obtains cryptographic
grade random bits from /dev/urandom on a Unix-like system, including Linux and macOS, while on
Windows it uses CryptGenRandom.
From version 3.6 however, the usage of random.SystemRandom() is not recommended anymore, and
the secrets module (that has a similar syntax) must be preferred.
Here is a simple Python script that shows password generation before and after the secrets module
appearance :
#!/usr/bin/env python3
import sys
import string
def getRandPwd(length):
alphabet = string.ascii_letters + string.digits # [a-zA-Z0-9]
if sys.version_info < (3, 6):
rng = random.SystemRandom()
return ''.join(rng.choice(alphabet) for _ in range(length))
else:
return ''.join(secrets.choice(alphabet) for _ in range(length))
password = getRandPwd(32)
Downloaded by Cp S ([email protected])
lOMoARcPSD|26093351
print(password)
PHP
A PHP program can open and read from /dev/urandom, if available, or invoke the Microsoft
utilities. A third option, if OpenSSL is available is to employ the
function openssl_random_pseudo_bytes'.'
Mechanical methods
Yet another method is to use physical devices such as dice to generate the randomness. One simple
way to do this uses a 6 by 6 table of characters. The first die roll selects a row in the table and the
second a column. So, for example, a roll of 2 followed by a roll of 4 would select the letter "j" from
the fractionation table below. To generate upper/lower case characters or some symbols a coin flip
can be used, heads capital, tails lower case. If a digit was selected in the dice rolls, a heads coin flip
might select the symbol above it on a standard keyboard, such as the '$' above the '4' instead of '4'.
1 2 3 4 5 6
1 a b c d e f
2 g h i j k l
3 m n o p q r
4 s t u v w x
5 y z 0 1 2 3
6 4 5 6 7 8 9
Downloaded by Cp S ([email protected])
lOMoARcPSD|26093351
Random password generators normally output a string of symbols of specified length. These can be
individual characters from some character set, syllables designed to form pronounceable passwords,
or words from some word list to form a passphrase. The program can be customized to ensure the
resulting password complies with the local password policy, say by always producing a mix of
letters, numbers and special characters. Such policies typically reduce strength slightly below the
formula that follows, because symbols are no longer independently produced.
The Password strength of a random password against a particular attack (brute-force search), can be
calculated by computing the information entropy of the random process that produced it. If each
symbol in the password is produced independently and with uniform probability, the entropy in bits
where N is the number of possible symbols and L is the number of symbols in the
password. The function log2 is the base-2 logarithm. H is typically measured in bits.
Downloaded by Cp S ([email protected])
lOMoARcPSD|26093351
All ex
Desi
All A tende
red Case Case
Ara Case SCII d
pass Case sensiti sensiti
bic insensiti print ASCI Dicewa
wor Hexad insensitive a ve Lati ve
num ve Latin able I re wor
d ecimal lphanumeri n alphan
eral alphabe char printa d list
entr c alphab umeri
s t acter ble
opy et c
s chara
H
cters
32
10 8 7 7 6 6 5 5 3
bits
Downloaded by Cp S ([email protected])
lOMoARcPSD|26093351
40
13 10 9 8 8 7 7 6 4
bits
64
20 16 14 13 12 11 10 9 5
bits
80
25 20 18 16 15 14 13 11 7
bits
96
29 24 21 19 17 17 15 13 8
bits
128
39 32 28 25 23 22 20 17 10
bits
160
49 40 35 31 29 27 25 21 13
bits
192
58 48 41 38 34 33 30 25 15
bits
224
68 56 48 44 40 38 35 29 18
bits
256
78 64 55 50 45 43 39 33 20
bits
116 96 82 75 68 65 59 50 30
384
Downloaded by Cp S ([email protected])
lOMoARcPSD|26093351
bits
512
155 128 109 100 90 86 78 66 40
bits
1024
309 256 218 199 180 172 156 132 80
bits
Any password generator is limited by the state space of the pseudo-random number generator
used if it is based on one. Thus a password generated using a 32-bit generator is limited to 32
bits entropy, regardless of the number of characters the password contains.
Note, however, that a different type of attack might succeed against a password evaluated as
'very strong' by the above calculation.
Downloaded by Cp S ([email protected])
lOMoARcPSD|26093351
5. PROJECT PREQUISITES
Guido van Rossum began working on Python in the late 1980s, as a successor to the ABC
programming language, and first released it in 1991 as Python 0.9.0. Python 2.0 was released in 2000
and introduced new features, such as list comprehensions and a cycle-detecting garbage collection
system (in addition to reference counting). Python 3.0 was released in 2008 and was a major revision
of the language that is not completely backward-compatible. Python 2 was discontinued with
version 2.7.18 in 2020.
To build this project we will use the basic concept of python and libraries – Tkinter, pyperclip,
random, string.
Tkinter is a standard GUI library and is one of the easiest ways to build a GUI
application.
pyperclip module allows us to copy and paste text to and from the clipboard to your
computer
The random module can generate random numbers
string module contains a number of functions to process the standard python string.
To install the libraries we can use pip installer from the command line:
Downloaded by Cp S ([email protected])
lOMoARcPSD|26093351
6. IMPLEMENTATION
Import modules
Initialized Window
Select Password Length
Define Functions
1. Import Libraries
2. Initialize Window
root = Tk()
root.geometry("400x400")
root.resizable(0,0)
root.title("DataFlair - PASSWORD GENERATOR")
Downloaded by Cp S ([email protected])
lOMoARcPSD|26093351
Label() widget use to display one or more than one line of text that users can’t able to modify.
root is the name which we refer to our window
text which we display on the label
font in which the text is written
pack organized widget in block
pass_str = StringVar()
def Generator():
password = ''
for x in range (0,4):
password = random.choice(string.ascii_uppercase) + random.choice(string.ascii_lowercase) +
random.choice(string.digits) + random.choice(string.punctuation)
for y in range(pass_len.get()- 4):
password = password + random.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits +
string.punctuation)
pass_str.set(password)
Downloaded by Cp S ([email protected])
lOMoARcPSD|26093351
First loop will generate a string of length 4 which is a combination of an uppercase letter,
a lowercase letter, digits, and a special symbol and that string will store in password
variable.
The second loop will generate a random string of length entered by the user – 4 and add
to the password variable. Here we minus 4 to the length of the user because we already
generate the string of length 4.
We have done this because we want a password which must contain an uppercase, a lowercase, a
digit, and a special symbol.
def Copy_password():
pyperclip.copy(pass_str.get())
Button(root, text = 'COPY TO CLIPBOARD', command = Copy_password).pack(pady=5)
Downloaded by Cp S ([email protected])
lOMoARcPSD|26093351
#=====================================WINDOW=========================
==========
gui = Tk()
gui.title("Password Generator")
width = 600
height = 262
screen_width = gui.winfo_screenwidth()
screen_height = gui.winfo_screenheight()
x = (screen_width/2) - (width/2)
Downloaded by Cp S ([email protected])
lOMoARcPSD|26093351
y = (screen_height/2) - (height/2)
gui.geometry("%dx%d+%d+%d" % (width, height, x, y))
#====================================VARIABLES=========================
=========
PASSWORD = StringVar()
PW_SIZE = IntVar()
e1 = Entry(gui, text=PW_SIZE)
PW_SIZE.set(8) # sets the default value for PW size/length
#====================================FRAME============================
==========
Top = Frame(gui, width=width)
Top.pack(side=TOP)
Form = Frame(gui, width=width)
Form.pack(side=TOP)
Bot = Frame(gui, width=width)
Bot.pack(side=BOTTOM)
#====================================LABELWIDGET======================
=========
lbl_title = Label(Top, width=width, font=('sans serif', 12, 'bold'), text="Select: Size >> Click:
Generate Now", bd=1, relief=SOLID)
lbl_title.pack(fill=X)
lbl_password = Label(Form, font=('sans serif', 18), text="Password", bd=10)
lbl_password.grid(row=0, pady=10)
lbl_strength = Label(Form, font=('sans serif', 10, 'bold'), foreground="white",
background="#6d0001", text="Weak", bd=10, height=1, width=10)
lbl_strength.grid(row=0, column=3, pady=10, padx=10)
lbl_pw_size = Label(Form, font=('sans serif', 18), text="Size", bd=10)
lbl_pw_size.grid(row=1, pady=10)
lbl_instructions = Label(Bot, width=width, font=('sans serif', 12, 'bold'), text="Result will be on
clipboard.", bd=1, relief=SOLID)
lbl_instructions.pack(fill=X)
Downloaded by Cp S ([email protected])
lOMoARcPSD|26093351
#====================================ENTRYWIDGET======================
=========
password = Entry(Form, textvariable=PASSWORD, font=(18), width=24)
password.grid(row=0, column=1, columnspan=2)
pw_size = Scale(Form, from_=8, to=24, length=230,width=24,sliderlength=14,
orient=HORIZONTAL, variable=PW_SIZE, font=(18))
pw_size.grid(row=1, column=1, columnspan=2)
#====================================BUTTONWIDGET====================
==========
btn_generate = Button(Form, text="Generate Now", width=20, command=lambda:
pwGenerator(PW_SIZE))
btn_generate.grid(row=2, column=1, columnspan=2)
#=======================================INITIATOR=======================
==========
gui.mainloop()
Downloaded by Cp S ([email protected])
lOMoARcPSD|26093351
8. TESTING
Testing Objectives:
The main objective of testing is to uncover a host of errors, systematically and with
minimum effort and time. Stating formally, we can say,
o Testing is a process of executing a program with the intent of finding an
error.
o A successful test is one that uncovers an as yet undiscovered error.
o The tests are inadequate to detect possibly present errors.
o The software more or less confirms to the quality and reliable standards.
Unit Testing :
▪ The purpose of the coding and unit testing phase of software development
is to translate the software design into source code. Each component of
the design is implemented as a program module. The end-product of this
phase is a set of program modules that have been individually tested. To
enable the engineers to write good quality programs, every software
development organization normally formulates its own coding standard
that suits itself. A coding standard addresses issues such as the standard
ways of laying out the program codes, the template for laying out the
function and module headers, commenting guidelines, variable and
function naming conventions, the maximum number of source lines
permitted in each module, and so forth.
▪ During this phase, each module is unit tested to determine the correct
working of all the individual modules. It involves testing each module in
isolation as this is the most efficient way to debug the errors identified at
Downloaded by Cp S ([email protected])
lOMoARcPSD|26093351
this stage. Another reason behind testing a module in isolation is that the
other modules, with which this module has to be interfaced, may not be
ready.
Integration of different modules is undertaken once they have been coded and
unit tested. During the integration and syste3m testing phase, the modules are
integrated in a planned manner. The different modules making up a software product
are almost never integrated in one shot. Integration is normally carried out
incrementally over a number of steps. During each integration step, the partially
integrated system is tested and a set of previously planned modules are added to it.
Finally, when all the modules have been successfully integrated and tested, system
testing is carried out. The goal of system testing is to ensure that the developed system
conforms to its requirements laid out in the SRS document.
Our project is integrated and tested by using an activity by name ∝- testing. ∝- testing
is the system testing performed by Zaid Nawaz, Varun Upadhyay.
Downloaded by Cp S ([email protected])
lOMoARcPSD|26093351
CONCLUSIONS
That’s it!!!
Here we are completed with our GUI Project using Python Tkinter.
With these steps, we have successfully created a random password generator
project using python. We used popular tkinter library to rendering graphics
in our display window and we also learned about pyperclip and random
library.
We learned how to create buttons, input textfield, labels, and spinbox. In this
way, we successfully created our password generator python project. Hope
you enjoyed it.
Downloaded by Cp S ([email protected])
lOMoARcPSD|26093351
BIBLIOGRAPHY
❖ Books:
❖ Websites:
https://www.python.org/
https://www.geeksforgeeks.org/
https://www.wikipedia.org/
https://github.com/
Downloaded by Cp S ([email protected])