Mini Project (Ramdom Password Gernator)
Mini Project (Ramdom Password Gernator)
Synopsis/Project Report
On
Random Password Generator and Manager
Assistant Professor
Department of CSE
We, Adarsh Singh Bajkoti, Shaurya Tiwari here by declare the work, which is being presented in the project,
entitled “random password generator and Manager” in partial fulfillment of the requirement for the award of
the degree B.Tech in the session 2022-2023, is an authentic record of my own work carried out under the
supervision of Mr. Shashi Kumar Sharma, Assistant Professor, Department of CSE, Graphic Era Hill
University, Bhimtal.
The matter embodied in this project has not been submitted by us for the award of any other degree.
Date:
Shaurya Tiwari
CERTIFICATE
The project report entitled “Random Password Generator and Manager ” being submitted by Adarsh
Singh Bajkoti and Shaurya Tiwari to Graphic Era Hill University Bhimtal Campus for the award of
bonafide work carried out by them. They have worked under my guidance and supervision and fulfilled the
requirement for the submission of report.
We take immense pleasure in thanking Honorable “Mr. Shashi Kumar Sharma” (Assistant
Professor, CSE, GEHU Bhimtal Campus) for permitting me and carry out this project work with his
excellent and optimistic supervision. This has all been possible due to his novel inspiration, able guidance and
useful suggestions that helped me to develop as a creative researcher and complete the research work, in time.
Words are inadequate in offering my thanks to GOD for providing me everything that we need. We again
want to extend thanks to our President “Prof. (Dr.) Kamal Ghanshala” for providing us all infrastructure and
facilities to work in need without which this work could not be possible.
Many thanks to Professor “Dr. Manoj Chandra Lohani” (Director Gehu Bhimtal),
other faculties for their insightful comments, constructive suggestions, valuable advice, and time in reviewing
this thesis.
Finally, yet importantly, we would like to express my heartiest thanks to our beloved parents,
for their moral support, affection and blessings. We would also like to pay our sincere thanks to all our friends
and well-wishers for their help and wishes for the successful completion of this research.
Shaurya Tiwari
Contents
DECLARATION III
CERTIFICATE IV
ACKNOWLEDGEMENT V
ABSTRACT VI
CHAPTER 1 (INTRODUCTION)
CHAPTER 2 (PROJECT
OVERVIEW)CHAPTER 3
(OBJECTIVE)
CHAPTER 7
(IMPLEMENTATION)
CHAPTER 8 (TESTING)
CONCLUSIN
BIBLIOGRA
HY
ABSTRACT
A random password generator and Manager 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, orthey
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.
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.
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.
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
togenerate 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
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
const rand = new Uint32Array(1)
do {
num = crypto.getRandomValues(rand)[0]
} while (num < min)
Perl
This example uses the Crypt::Random:: Source module to find a source of strong random numbers
(which is platform dependent).
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
import random
else: # Python 3.6 and above
import secrets
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))
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
TYPES AND STRENGTH OF PASSWORD GENERATED
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.
All ex
Desi All A
tende
red Case Case
Ara Case SCII
Case d
pass sensiti sensiti
bic insensiti insensitive a print Dicewa
ASCI
wor Hexad ve Lati ve
num ve Latin lphanumeri able re wor
I
d ecimal n alphan
eral alphabe char d list
c printa
entr alphab umeri
s t acter
ble
opy et c
s
chara
H
cters
32
10 8 7 7 6 6 5 5 3
bits
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
384 116 96 82 75 68 65 59 50 30
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 generatorused if it is based
on one. Thus a password generated using a 32-bit generator is limited to 32bits 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.
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.
1. Importing Required Libraries: The code begins with importing the necessary libraries:
To build this project we will use the basic concept of python and libraries – Tkinter, secrets,
tkinter, messagebox, os, strings
• secrets: It provides access to secure random numbers suitable for generating passwords.
• string: It includes a collection of string constants containing ASCII characters used for generating
passwords.
• tkinter: It is the standard Python interface to the Tk GUI toolkit.
• messagebox: It provides a simple way to display message boxes in Tkinter.
• os: It provides a way to use operating system-dependent functionality (in this case, creating directories and
files).
import secrets
import string
import tkinter as tk
from tkinter import messagebox
import os
2. Variable Initialization:
def generate_password(size=10):
characters = string.ascii_letters + string.digits + string.punctuation
new_password = ''.join(secrets.choice(characters) for _ in range(size))
PASSWORD.set(new_password)
gui.clipboard_clear()
gui.clipboard_append(new_password)
gui.update()
passwords.append(new_password) # Add generated password to the list
determine_password_strength(new_password) # Determine the strength of the password
def determine_password_strength(password):
length = len(password)
strength = ""
if length < 8:
strength = "Weak"
elif length < 12:
strength = "Medium"
else:
strength = "Strong"
lbl_strength.config(text=f"Length: {length}, Strength: {strength}")
def save_password():
password = PASSWORD.get()
if password:
passwords.append(password) # Add manually entered password to the list
save_to_file(password)
messagebox.showinfo("Password Manager", "Password saved successfully!")
else:
messagebox.showerror("Password Manager", "No password to save!")
• save_password: This function gets the current value of the PASSWORD variable (which is associated with
the entry widget in the GUI).
• If a password is present, it adds it to the passwords list, saves it to a file using the save_to_file
function, and displays a success message box.
• If no password is entered, it displays an error message box.
5. Save to File Function:
def save_to_file(password):
index = len(passwords)
folder = "passwords"
if not os.path.exists(folder):
os.makedirs(folder)
filename = f"{folder}/{index}.txt"
with open(filename, "w") as file:
file.write(password)
6. GUI Creation:
gui = tk.Tk()
gui.title("Password Generator and Manager")
• It creates the main Tkinter GUI window with the title "Password Generator and Manager."
7. Variable Initialization:
PASSWORD = tk.StringVar()
PW_SIZE = tk.IntVar()
PW_SIZE.set(8) # sets the default value for PW size/length
• PASSWORD: It is a Tkinter variable used to store the current value of the password entry widget.
• PW_SIZE: It is a Tkinter variable used to store the current value of the password size slider. It is initialized
with a default value of 8.
8. Frame Creation:
Form = tk.Frame(gui)
Form.pack(side=tk.TOP)
Bot = tk.Frame(gui)
Bot.pack(side=tk.BOTTOM)
• Form: It is a Tkinter frame that will contain the password-related widgets at the top of the GUI.
• Bot: It is a Tkinter frame that will contain other widgets at the bottom of the GUI.
9. Label Creation:
lbl_password = tk.Label(Form, font=('sans serif', 18), text="Password", bd=10)
lbl_password.grid(row=0, pady=10)
lbl_pw_size = tk.Label(Form, font=('sans serif', 18), text="Size", bd=10)
lbl_pw_size.grid(row=1, pady=10)
lbl_strength = tk.Label(Form, font=('sans serif', 10, 'bold'), foreground="black", text="", bd=10, height=1,
width=20)
lbl_strength.grid(row=0, column=3, pady=10, padx=10)
• lbl_password: It is a label widget that displays the text "Password" and is formatted with a font and border
size. It is placed in the Form frame at row 0.
• lbl_pw_size: It is a label widget that displays the text "Size" and is formatted with a font and border size. It
is placed in the Form frame at row 1.
• lbl_strength: It is a label widget that displays the length and strength of the password. It is initially empty. It
is placed in the Form frame at row 0 and column 3.
10. Entry and Scale Widget Creation:
• password: It is an entry widget used to display the generated password and allow manual password input. It
is associated with the PASSWORD variable and placed in the Form frame at row 0 and columns 1-2.
• pw_size: It is a scale widget used to select the size/length of the password. It ranges from 8 to 24, has a
length and width defined, and is associated with the PW_SIZE variable. It is placed in the Form frame at
row 1 and columns 1-2.
• btn_generate: It is a button widget labeled "Generate Now" that calls the generate password function when
clicked. It is placed in the Form frame at row 2 and columns 1-2.
• btn_save: It is a button widget labeled "Save Password" that calls the save password function when clicked.
It is placed in the Form frame at row 3 and columns 1-2.
12. Running the GUI:
gui.mainloop( )
• It starts the main event loop for the Tkinter GUI, which handles user input and updates the GUI's
appearance.
OUTPUT:-
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 layingout 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
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.
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 text field, labels, and spin box. In this way,
wesuccessfully created our password generator python project. Hope you enjoyed it.
BIBLIOGRAPHY
❖ Websites:
https://www.python.org/
https://www.geeksforgeeks.org/
https://www.wikipedia.org/
https://github.com/