RANDOM PASSWORD GENERATOR USING PYTHON
Chapter 1:
Introduction
1.1 Introduction
A password is a string of characters used to verify the identity of a user during the
authentication process . Passwords are typically used in tandem with a username; they are
designed to be known only to the user and allow that user to gain access to a device,
application or website.
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.
1.2 Problem Statement
Develop a user-friendly program that generates passwords for the users.
1.3 Project Aim & Objective
The objective is to create a program on password generator tool using python programming
language .
As there is an increase in cybercrimes and hacking it is necessary to keep passwords that are
not easily guessable. Keeping a password that is not so easy to be found lessens the chances
to be vulnerable to such threats. Hence this program helps you to generate random passwords
that cannot be easily guessed.
1
DEPARTMENT OF ARTIFICAL INTELLIGENCE AND MACHINE LEARNING
FACULTY OF ENGINNERING AND TECHNOLOGY (EXCLUSIVE FOR WOMEN)
RANDOM PASSWORD GENERATOR USING PYTHON
For a secure and strong password remainder the following:
● Never use personal information
● Include a combination of letters, numbers and characters.
● Prioritize password length.
● Never repeat passwords.
● Avoid using real words.
Strong password:
● Long: The longer a password, the more secure it is. A strong password should be
atleast 12 characters long.
● Random: Strong passwords use a combination of letters, numbers, cases and
symbols to form an unpredictable string of characters that doesn’t resemble word or
names.
● Unique: A strong password should be unique to each account to reduce
vulnerability in the event of a hack.
2
DEPARTMENT OF ARTIFICAL INTELLIGENCE AND MACHINE LEARNING
FACULTY OF ENGINNERING AND TECHNOLOGY (EXCLUSIVE FOR WOMEN)
RANDOM PASSWORD GENERATOR USING PYTHON
Chapter 2:
Language Specification
2.1 Introduction to python
Python is a popular programming language. It was created by Guido van Rossum, and
released in 1991.
It is used for:
● web development (server-side),
● software development,
● mathematics,
● system scripting
Python is a widely used general-purpose, high level programming language. It was
created by Guido van Rossum in 1991 and further developed by the Python Software
Foundation. It was designed with an emphasis on code readability, and its syntax
allows programmers to express their concepts in fewer lines of code. Python is a
programming language that lets you work quickly and integrate systems more
efficiently. There are two major Python versions: Python 2 and Python 3. Both are
quite different
• Add, modify, and delete
tasks for a particular day.
• Save and load tasks from a
file for future reference.
3
DEPARTMENT OF ARTIFICAL INTELLIGENCE AND MACHINE LEARNING
FACULTY OF ENGINNERING AND TECHNOLOGY (EXCLUSIVE FOR WOMEN)
RANDOM PASSWORD GENERATOR USING PYTHON
• Search for tasks based on
their descriptions and make
changes as needed.
• Add, modify, and delete tasks for a particular day.
• Save and load tasks from a file for future reference.
• Search for tasks based on their descriptions and make changes as needed.
2.2 Why use Python?
● Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc).
● Python has a simple syntax similar to the English language.
● Python has syntax that allows developers to write programs with fewer lines than
some other programming languages.
● Python runs on an interpreter system, meaning that code can be executed as soon as
it is written. This means that prototyping can be very quick.
● Python can be treated in a procedural way, an object-oriented way or a functional
way.
2.3 INSTALLATION
• Usually, pip is automatically installed if you are:
• Working in a virtual environment.
• Using python downloaded from python.org.
• Using python that has not been modified by a re-distributor to remove ensure pip
Step 1: Downloading the python installer
1.Go to the official Python Download page for windows.
2.Find a stable Python 3 release. This tutorial was tested with Python version 3.10.10
3. click the appropriate link for your system to download the executable file. windows
installer(64-bit) or windows installer(32-bit).
Step 2: Running the Executable Installer
1.After the installer is downloaded, double-click the .exes file, for example python-3.10.10-
4
DEPARTMENT OF ARTIFICAL INTELLIGENCE AND MACHINE LEARNING
FACULTY OF ENGINNERING AND TECHNOLOGY (EXCLUSIVE FOR WOMEN)
RANDOM PASSWORD GENERATOR USING PYTHON
amd64.exes,to run the Python installer.
2.Select the Install launcher for all users checkbox, which enables all users of the computer
toaccess the Python launcher application.
3.Select the Add python.exes to PATH checkbox, which enables users to launch Python from
the command line.
4.The Optional If you’re just getting started with Python and you want to install it with
default
features as described in the dialog, then click Install Now and go to.
Step 3:Verify the Python Installation.
To install other optional and advanced features, click Customize installation and continue.
1.The Optional Features include common tools and resources for Python and you can install
all of them, even if you don’t plan to use them.
Select some or all of the following options:
• Documentation: recommended.
• pip: recommended if you want to install other Python packages, such as Bumpy or
pandas.
• IDLE: recommended if you plan to use IDLE or follow tutorials that use it.
• Python test suite: recommended for testing and learning.
• Python launcher and for all users: recommended to enable users to launch Python from
the command line.
2.Click Next.
3.The Advanced Options dialog display.
Select the options that suit your requirements:
• Install for all users: recommended if you’re not the only user on this computer.
• Associate files with Python: recommended, because this option associates all the
Python file types with the launcher or editor.
• Create shortcuts for installed applications: recommended to enable shortcuts for Python
applications.
• Add Python to environment variables: recommended to enable launching Python.
• P-recompile standard library: not required, it might down the installation
• Download debugging symbols and Download debug binaries: recommended only if
5
DEPARTMENT OF ARTIFICAL INTELLIGENCE AND MACHINE LEARNING
FACULTY OF ENGINNERING AND TECHNOLOGY (EXCLUSIVE FOR WOMEN)
RANDOM PASSWORD GENERATOR USING PYTHON
you plan to create C or C++ extensions.
Make note of the Python installation directory in case you need to reference it later.
4.Click Install to start the installation.
5.After the installation is complete, a Setup was successful message displays python setup
was
successful.
Step 4:Adding Python to the Environment Variables (optional)
Skip this step if you selected Add Python to environment variables during installation. If you
want to access Python through the command line but you didn’t add Python to your
environment variables during installation, then you can still do it manually.
Before you start, locate the Python installation directory on your system. The following
directories are examples of the default directory paths:
• C:\Program Files\Python310: if you selected Install for all users during installation,
then the directory will be system wide
• C:\Users\Sammy\App Data\Local\Programs\Python\Python310: if you didn’t select
Install for all users during installation, then the directory will be in the Windows user
path
Note that the folder name will be different if you installed a different version, but will still
start
with Python.
1.Go to Start and enter advanced system settings in the search bar.
2.Click View advanced system settings.
3.In the System Properties dialog, click the Advanced tab and then click Environment
Variables.
4.Depending on your installation:
• If you selected Install for all users during installation, select Path from the list of System
Variables and click Edit.
• If you didn’t select Install for all users during installation, select Path from the list of
User Variables and click Edit.
5.Click New and enter the Python directory path, then click OK until all the dialog s are
closed.
Step 5 :Verify the Python Installation
You can verify whether the Python installation is successful either through the command line
6
DEPARTMENT OF ARTIFICAL INTELLIGENCE AND MACHINE LEARNING
FACULTY OF ENGINNERING AND TECHNOLOGY (EXCLUSIVE FOR WOMEN)
RANDOM PASSWORD GENERATOR USING PYTHON
or through the Integrated Development Environment (IDLE) application, if you chose to
install
it.Go to Start and enter command in the search bar. Click Command Prompt.
Enter the following command in the command prompt :python --version
An example of the output is:
Output
Python 3.10.10
You can also check the version of Python by opening the IDLE application. Go to Start and
enter python in the search bar and then click the IDLE app, for example IDLE (Python 3.10
64-bit).You can start coding in python using IDLE or your preferred code editor.
2.4 Features in Python
There are many features in Python, some of which are discussed below as follows:
1. Free and Open Source: Python language is freely available at the official website and you
can download it from the given download link below click on the Download
Python keyword. Download Python Since it is open-source, this means that source code is
also
available to the public. So you can download it, use it as well as share it.
2. Easy to code: Python is a high-level programming language. Python is very easy to learn
the
language as compared to other languages like C, C#, Javascript, Java, etc. It is very easy to
code in the Python language and anybody can learn Python basics in a few hours or days. It is
also a developer-friendly language.
3. Easy to Read: As you will see, learning Python is quite simple. As was already established,
Python’s syntax is really straightforward. The code block is defined by the indentations rather
than by semicolons or brackets.
4. Object-Oriented Language: One of the key features of Python is Object-Oriented
programming. Python supports object-oriented language and concepts of classes, object
encapsulation, etc.
5. GUI Programming Support: Graphical User interfaces can be made using a module such
7
DEPARTMENT OF ARTIFICAL INTELLIGENCE AND MACHINE LEARNING
FACULTY OF ENGINNERING AND TECHNOLOGY (EXCLUSIVE FOR WOMEN)
RANDOM PASSWORD GENERATOR USING PYTHON
as PyQt5, PyQt4, wxPython, or Tk in Python. PyQt5 is the most popular option for creating
graphical apps with Python.
6. High-Level Language Python is a high-level language. When we write programs in
Python,
we do not need to remember the system architecture, nor do we need to manage the memory.
7. Large Community Support: Python has gained popularity over the years. Our questions are
constantly answered by the enormous Stack Overflow community. These websites have
already provided answers to many questions about Python, so Python users can consult them
as needed.
8. Easy to Debug:Excellent information for mistake tracing. You will be able to quickly
identify and correct the majority of your program’s issues once you understand how
to interpret Python’s error traces. Simply by glancing at the code, you can determine what it
is
designed to perform.
9. Python is a Portable language:Python language is also a portable language. For example, if
we have Python code for Windows and if we want to run this code on other platforms such
as Linux, Unix, and Mac then we do not need to change it, we can run this code on any
platform.
10. Python is an Integrated language:Python is also an Integrated language because we can
easily integrate Python with other languages like C, C++, etc.
11. Interpreted Language:Python is an Interpreted Language because Python code is executed
line by line at a time. like other languages C, C++, Java, etc. there is no need to compile
Python
code this makes it easier to debug our code. The source code of Python is converted into an
immediate form called bytecode.
8
DEPARTMENT OF ARTIFICAL INTELLIGENCE AND MACHINE LEARNING
FACULTY OF ENGINNERING AND TECHNOLOGY (EXCLUSIVE FOR WOMEN)
RANDOM PASSWORD GENERATOR USING PYTHON
2.5 Basic Structure of Python
The basic structure of a Python program consists of the following components:
1. Comments: Comments are used to explain the purpose of the code or to make
notes for other programmers. They start with a ‘#’ symbol and are ignored by the
interpreter.
2. Import Statements: Import statements are used to import modules or libraries into
the program. These modules contain predefined functions that can be used to
accomplish tasks.
3. Variables: Variables are used to store data in memory for later use. In Python,
variables do not need to be declared with a specific type.
4. Data Types: Python supports several built-in data types including integers, floats,
strings, booleans, and lists.
5. Operators: Operators are used to perform operations on variables and data.
Python supports arithmetic, comparison, and logical operators.
6. Control Structures: Control structures are used to control the flow of a program.
Python supports if-else statements, for loops, and while loops.
7. Functions: Functions are used to group a set of related statements together and
give them a name. They can be reused throughout a program.
8. Classes: Classes are used to define objects that have specific attributes and
methods. They are used to create more complex data structures and encapsulate
code.
9. Exceptions: Exceptions are used to handle errors that may occur during the
execution of a program.
2.5 Data types
The following are the standard or built-in data types in Python:
9
DEPARTMENT OF ARTIFICAL INTELLIGENCE AND MACHINE LEARNING
FACULTY OF ENGINNERING AND TECHNOLOGY (EXCLUSIVE FOR WOMEN)
RANDOM PASSWORD GENERATOR USING PYTHON
● Numeric
● Sequence Type
● Boolean
● Set
● Dictionary
● Binary Types( memoryview , bytearray , bytes )
1. Numeric Data Types in Python
● Integers – This value is represented by int class. It contains positive or negative
whole numbers (without fractions or decimals). In Python, there is no limit to how
long an integer value can be.
● Float – This value is represented by the float class. It is a real number with a
floating-point representation. It is specified by a decimal point. Optionally, the
character e or E followed by a positive or negative integer may be appended to
specify scientific notation.
● Complex Numbers – A complex number is represented by a complex class. It is
specified as (real part) + (imaginary part)j . For example – 2+3j
Example:
a=5
print("Type of a: ", type(a))
b = 5.0
print("\nType of b: ", type(b))
c = 2 + 4j
print("\nType of c: ", type(c))
10
DEPARTMENT OF ARTIFICAL INTELLIGENCE AND MACHINE LEARNING
FACULTY OF ENGINNERING AND TECHNOLOGY (EXCLUSIVE FOR WOMEN)
RANDOM PASSWORD GENERATOR USING PYTHON
2. Sequence Data Types in Python
There are several sequence data types of Python:
● Python String
● Python List
● Python Tuple
String Data Type
Strings in Python are arrays of bytes representing Unicode characters. A string is a collection
of one or more characters put in a single quote, double-quote, or triple-quote. In Python, there
is no character data type Python, a character is a string of length one. It is represented by str
class.
Creating String
Strings in Python can be created using single quotes, double quotes, or even triple quotes.
Example:
String1 = 'Welcome to the Geeks World'
print("String with the use of Single Quotes: ")
print(String1)
String1 = "I'm a Geek"
print("\nString with the use of Double Quotes: ")
print(String1)
print(type(String1))
String1 = '''I'm a Geek and I live in a world of "Geeks"'''
print("\nString with the use of Triple Quotes: ")
11
DEPARTMENT OF ARTIFICAL INTELLIGENCE AND MACHINE LEARNING
FACULTY OF ENGINNERING AND TECHNOLOGY (EXCLUSIVE FOR WOMEN)
RANDOM PASSWORD GENERATOR USING PYTHON
List Data Type
Lists are just like arrays, declared in other languages which is an ordered collection of data. It
is very flexible as the items in a list do not need to be of the same type.
Example: List = []
print("Initial blank List: ")
print(List)
List = ['GeeksForGeeks']
print("\nList with the use of String: ")
print(List)
Tuple Data Type
Just like a list, a tuple is also an ordered collection of Python objects. The only difference
between a tuple and a list is that tuples are immutable i.e. tuples cannot be modified after it is
created. It is represented by a tuple class.
Example :
Tuple1 = ()
print("Initial empty Tuple: ")
print(Tuple1)
Tuple1 = ('Geeks', 'For')
print("\nTuple with the use of String: ")
print(Tuple1)
3. Boolean Data Type in Python
Python Data type with one of the two built-in values, True or False. Boolean objects that are
equal to True are truthy (true), and those equal to False are falsy (false). However non-
Boolean objects can be evaluated in a Boolean context as well and determined to be true or
false. It is denoted by the class bool.
Example :
print(type(True))
print(type(False))
12
DEPARTMENT OF ARTIFICAL INTELLIGENCE AND MACHINE LEARNING
FACULTY OF ENGINNERING AND TECHNOLOGY (EXCLUSIVE FOR WOMEN)
RANDOM PASSWORD GENERATOR USING PYTHON
print(type(true))
4. Set Data Type in Python
In Python Data Types, a Set is an unordered collection of data types that is iterable, mutable,
and has no duplicate elements. The order of elements in a set is undefined though it may
consist of various elements.
Example :
set1 = set()
print("Initial blank Set: ")
print(set1)
set1 = set("GeeksForGeeks")
print("\nSet with the use of String: ")
print(set1)
5. Dictionary Data Type in Python
A dictionary in Python is an unordered collection of data values, used to store data values like
a map, unlike other Python Data Types that hold only a single value as an element, a
Dictionary holds a key: value pair. Key-value is provided in the dictionary to make it more
optimized. Each key-value pair in a Dictionary is separated by a colon : , whereas each key is
separated by a ‘comma’.
Example :
Dict = {1: 'Geeks', 2: 'For', 3: 'Geeks'}
print("\nDictionary with the use of Integer Keys: ")
print(Dict)
Dict = {'Name': 'Geeks', 1: [1, 2, 3, 4]}
print("\nDictionary with the use of Mixed Keys: ")
print(Dict)
2.5 Modules used
string – For accessing string constants. The ones we would need are –
13
DEPARTMENT OF ARTIFICAL INTELLIGENCE AND MACHINE LEARNING
FACULTY OF ENGINNERING AND TECHNOLOGY (EXCLUSIVE FOR WOMEN)
RANDOM PASSWORD GENERATOR USING PYTHON
● string.ascii_letters: ASCII is a system that is used to represent characters
digitally, every ASCII character has its own unique code. string.ascii_letters is a
string constant which contains all the letters in ASCII ranging from A to Z and a
to z. Its value is non-locale dependent and it is just a concatenation of
ascii_uppercase and ascii_lowercase. Thus it provides us the whole letter set as a
string that can be used as desired.
● string.digits: This is a pre-initialized string that contains all the digits in the
Arabic numeral system i.e. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. It should be kept in mind that
even though these are digits, the type is still a string constant, and all digits are
concatenated like this – “0123456789”. If we want to access specific numbers
then we can do so using slicing.
● string.punctuation: Apart from letters and digits, python also provides us all the
special characters in a pre-initialized string constant. These include various kinds
of braces, logical operators, comparison operators, arithmetical operators as well
as punctuation marks like commas, inverted commas, periods, exclamations
marks, and question marks. The whole string is – !”#$%&'()*+, -./:;<=>?
@[\]^_`{|}~
random – The python random module helps a user to generate pseudo-random numbers.
Inside the module, there are various functions that just depend on the function “random()”.
This function generates a random float uniformly in the semi-open range [0.0, 1.0) i.e. it
generates a decimal number greater than or equal to 0 and strictly less than one. Other
functions use this number in their own ways. These functions can be used for bytes, integers,
and sequences. for our task, we are interested in sequences. There are functions
random. choices that take in a sequence as its argument and return a random element from
that sequence
14
DEPARTMENT OF ARTIFICAL INTELLIGENCE AND MACHINE LEARNING
FACULTY OF ENGINNERING AND TECHNOLOGY (EXCLUSIVE FOR WOMEN)
RANDOM PASSWORD GENERATOR USING PYTHON
CHAPTER 3
SYSTEM SPECIFICATION
HARDWARE REQUIREMENTS
1. Processor : intel coreTM i3-5005 CPU
2. RAM :3.8 GiB
SOFTWARE REQUIREMENTS
1. OS : fedora (64-bit)/Windows 10 or above
2. Language: C language
15
DEPARTMENT OF ARTIFICAL INTELLIGENCE AND MACHINE LEARNING
FACULTY OF ENGINNERING AND TECHNOLOGY (EXCLUSIVE FOR WOMEN)
RANDOM PASSWORD GENERATOR USING PYTHON
Chapter 4:
IMPLEMENTATION
import string
import random
# Getting password length
length = int(input("Enter password length: "))
print('''Choose character set for password from these :
1. Digits
2. Letters
3. Special characters
4. Exit''')
characterList = ""
# Getting character set for password
while(True):
choice = int(input("Pick a number "))
if(choice == 1):
# Adding letters to possible characters
characterList += string.ascii_letters
elif(choice == 2):
# Adding digits to possible characters
characterList += string.digits
elif(choice == 3):
# Adding special characters to possible
# characters
characterList += string.punctuation
16
DEPARTMENT OF ARTIFICAL INTELLIGENCE AND MACHINE LEARNING
FACULTY OF ENGINNERING AND TECHNOLOGY (EXCLUSIVE FOR WOMEN)
RANDOM PASSWORD GENERATOR USING PYTHON
elif(choice == 4):
break
else:
print("Please pick a valid option!")
password = []
for i in range(length):
# Picking a random character from our
# character list
randomchar = random.choice(characterList)
# appending a random character to password
password.append(randomchar)
# printing password as a string
print("The random password is " + "".join(password))
17
DEPARTMENT OF ARTIFICAL INTELLIGENCE AND MACHINE LEARNING
FACULTY OF ENGINNERING AND TECHNOLOGY (EXCLUSIVE FOR WOMEN)
RANDOM PASSWORD GENERATOR USING PYTHON
Chapter 5:
OUTPUT/RESULT
Here are results after running the code successfully
Input 1: Taking only letters in the character set
Input 2: Taking letters and numbers both
18
DEPARTMENT OF ARTIFICAL INTELLIGENCE AND MACHINE LEARNING
FACULTY OF ENGINNERING AND TECHNOLOGY (EXCLUSIVE FOR WOMEN)
RANDOM PASSWORD GENERATOR USING PYTHON
Input 3: Taking letters numbers as well as special characters
• The `delete_task` function
allows the user to delete a task
for a
19
DEPARTMENT OF ARTIFICAL INTELLIGENCE AND MACHINE LEARNING
FACULTY OF ENGINNERING AND TECHNOLOGY (EXCLUSIVE FOR WOMEN)
RANDOM PASSWORD GENERATOR USING PYTHON
Conclusion
With the help of this project one can easily generate a random password anytime he/she
wants. This project is very useful for those who are always in a perplexed state about what
password to use for a tight security purpose.
As these passwords are randomly generated, no one can ever guess them and therefore it
provides a tight security be it for lockers or any software et cetera which requires protection
from outsiders. We can also add many other features to improvise the code as per our
requirement and make sure that the resultant password is strong enough.
20
DEPARTMENT OF ARTIFICAL INTELLIGENCE AND MACHINE LEARNING
FACULTY OF ENGINNERING AND TECHNOLOGY (EXCLUSIVE FOR WOMEN)
RANDOM PASSWORD GENERATOR USING PYTHON
REFERENCES
1. http://www.wikipedia.com
2. http://www.w3c.com
1
DEPARTMENT OF ARTIFICAL INTELLIGENCE AND MACHINE LEARNING
FACULTY OF ENGINNERING AND TECHNOLOGY (EXCLUSIVE FOR WOMEN)