Pavithrakavya Mini Project Report
Pavithrakavya Mini Project Report
N.PAVITHRA 321244312
B.KAVYA 321244303
DURING
3RD SEMESTER 2024-2025
Reviewed by
1
DEEKSHA DEGREE COLLEGE
Near New Bus Stand, Nirmal
Certificate
DURING
3RD SEMESTER 2024-2025
2
CONTENTS
ABSTRACT 4
ACKNOWLEDGEMENT 5
INTRODUCTION
1.1. DEFINITION 1
1.2. OBJECTIVES 1
1.3. HARDWARE AND SOFTWARE REQUIREMENTS
2. DATASTRUCTURES
2.1. STRINGS 5
2.2. LISTS 6
2.3. INTEGERS
2.4. BOOLEANS
3. IMPLEMENATION 20
3.1. Generating a Numeric OTP
3.2. Customizing OTP Length
3.3. OTP Verification Process
3.4. Testing the OTP Generator
4. RESULTS 23
5. CONCLUSION 25
6.
3
ABSTRACT
The project involves the creation of an OTP generation system that produces a
random, numeric OTP. The OTP is sent to the user (optionally via email) and is valid only for
a limited time to ensure security. The user is then prompted to input the OTP, which is
validated by the system. If the OTP matches and has not expired, the system grants access;
otherwise, it displays an error message indicating that the OTP is invalid or expired.
4
ACKNOWLEDGEMENT
I would like to express my sincere gratitude to everyone who has supported and guided me
throughout the development of this Python mini project on the OTP Generator.
First and foremost, I would like to thank my project supervisor for their valuable
guidance, insightful suggestions, and continuous support throughout the course of this
project. Their expertise and encouragement have been instrumental in completing this
project successfully.
I also extend my heartfelt thanks to my family and friends for their constant
encouragement and understanding, which kept me motivated during the course of this
project.
A special thanks to of our project guide LAXMAN NYAMTABAD as well as our principal
M.SRIDHAR Garu who have the golden opportunity to do this wonderful project on the
topic SIMPLE OTP GENERATOR, which also helped us in doing a lot of research and we
came to know about so many new things we are really thankful to them
secondly I would also like to thank my parents and friends who helped me a lot in
finalizing this project within the limited time frame
Lastly, I would like to acknowledge the Python programming community, whose
open-source contributions and collaborative spirit have made it possible to create this
project with the rich libraries and modules available.
5
INTRODUCTION
In this project, we will create a Simple OTP Generator in Python. This generator will
generate a random OTP that can be sent to the user for authentication purposes. OTPs can
either be numeric or alphanumeric, and we will focus on generating numeric OTPs in this
example for simplicity.
In today’s digital world, ensuring security is crucial, especially for applications that
require user authentication. One-time passwords (OTPs) are widely used to verify the
identity of users during login or sensitive transactions. An OTP is a unique password that is
valid for only one session or transaction, providing an additional layer of security to prevent
unauthorized access.
Objectives:
Randomness: The OTP will be generated randomly to ensure that it is unique every time.
Fixed Length: The length of the OTP can be customized.
Time-based Expiry: The OTP will expire after a certain amount of time (optional feature).
Security: Since OTPs are short-lived, they are a secure way to ensure that only the intended
user can access a system or service.
Technologies Used:
Python: Programming language to implement the OTP generator.
Random module: For generating random numbers to create the OTP.
Time module: For managing OTP expiry (optional feature).
Use Case:This simple OTP generator can be used in any Python-based web or desktop
application where user verification is needed.
Examples include:
o User login systems
o Transaction verification
o Account recovery systems
6
In the upcoming sections, we will demonstrate how to implement the OTP generator in
Python.
Analysis:
o A 6-digit numeric OTP can be generated easily using Python's random.randint().
However, in real-world applications, additional complexity (like adding
alphanumeric characters or increasing the OTP length) may be necessary
depending on the security requirements.
o OTPs are often generated with varying lengths (e.g., 6 digits or 8 digits) based on
the sensitivity of the system they are used to protect. Longer OTPs are harder to
guess.
Objective: To create a basic OTP (One-Time Password) generator using Python, allowing
users to authenticate their identity securely.
Requirements:
In order to develop a Simple OTP Generator project, both hardware and
software requirements. The following are the key requirements for the project:
software requirements:
- Python Libraries and Modules
- Internet Connection (if Email Service is Used)
- Python version: Python 3.6
- Operating system: windows 10
Hardware Requirements:
7
ALGORITHM:
The OTP Generator project relies on a straightforward algorithm for generating,
validating, and expiring One-Time Passwords (OTPs).The algorithm's main
purpose is to provide secure, temporary, and random passwords for
authentication purposes.
8
If email integration is enabled, use the smtplib module to send the
OTP to the user's email address.
Format the email body with the OTP and expiration message.
Example: Send OTP to the provided email address using an SMTP
server (e.g., Gmail).
Return OTP:
Provide the generated OTP to the user, either via email (if email
integration is used) or print it on the screen for CLI-based
interaction.
Strings
Usage: The OTP is generated as a string of characters (either numeric or
alphanumeric).
Example:
otp = ''.join([str(random.randint(0, 9)) for _ in range(6)])
This line generates a 6-digit OTP by joining individual digits into a string.
Reason for Use:
The OTP is treated as a string because it's easier to handle and
display to users. A string can be easily checked for correctness (i.e.,
when a user inputs the OTP, it's compared as a string).
Lists
Usage: A list is used when generating the OTP to store individual digits
before joining them into a complete OTP string.
9
In this case, the list stores each digit as a string, and join() is used to combine them into one
continuous string.
Integers
Usage: Integers are used throughout the project, particularly in the generation of numeric
OTPs and to track timestamps and expiry times.
Example:
Booleans
Usage: Boolean values are used to determine if the OTP entered by the user is valid and
whether it has expired.
if input_otp == generated_otp:
Implementing
Generating a Numeric OTP:
import random
def generate_otp(length=6):
return otp
10
Customizing OTP Length:
Show how the length of the OTP can be customized by passing an argument to the function.
Here’s a simple Python code to generate and validate an OTP (One-Time Password) without
involving any email functionality.
11
Simple OTP Generator in Python:
import random
import time
def generate_otp(length=6):
return True
return False
12
if user_input == generated_otp: # Check if the user input
matches the generated OTP
else:
# Example usage
if __name__ == "__main__":
# Generate OTP
# Validate OTP
print(result)
Example Output:
OTP Valid
OTP Expired
CONCLUSION
13
The Simple OTP Generator project demonstrates the implementation of a basic yet
effective authentication mechanism using One-Time Passwords (OTPs). The system
generates random OTPs that are valid for a limited period (e.g., 5 minutes) and validates
them upon user input. This project provides a strong foundation for understanding the core
concepts of OTP generation, expiration, and validation.
14