0% found this document useful (0 votes)
2 views15 pages

Pythonotp

The document outlines a mini project on the development of an OTP (One Time Password) generator for enhancing user authentication security. It includes sections on the project's objectives, system analysis, design, implementation, and testing results, demonstrating the effectiveness of the OTP system in providing a secure authentication mechanism. The project is supervised by Mrs. Prachi Singh and is part of the requirements for a Bachelor of Technology degree in Computer Science and Engineering at Krishna Institute of Technology, Kanpur.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views15 pages

Pythonotp

The document outlines a mini project on the development of an OTP (One Time Password) generator for enhancing user authentication security. It includes sections on the project's objectives, system analysis, design, implementation, and testing results, demonstrating the effectiveness of the OTP system in providing a secure authentication mechanism. The project is supervised by Mrs. Prachi Singh and is part of the requirements for a Bachelor of Technology degree in Computer Science and Engineering at Krishna Institute of Technology, Kanpur.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Mini Project

On
Project Title
Submitted in OTP Generator of the Requirement For
the Degree of
Bachelor of Technology
In
Computer Science and Engineering
By
Monika : (2303510109052) Under the
Supervision
Of
Mrs. Prachi Singh (Asst. Professor)
KRISHANA INSTITUTE OF TECHNOLOGY, KANPUR

AFFILIATED TO
Dr A.P.J. ABDUL KALAM TECHNICAL UNIVERSITY, UTTAR PRADESH,
LUCKNOW (ODD SEM, 2025-26)

1
CERTIFICATE
This is to certify that Monika student of Krishna Institute Of Technology Rahul, Kanpur,
has successfully completed the project titled ―Portfolio Website Development‖ under the
guidance of Mrs. Prachi Asst .Professor during the academic year 2023–2026.
This project is submitted in partial fulfillment of the requirements for the award
of the degree [Link]
The project work presented in this report is original and has been carried out by
the student with dedication and sincerity.
Date:
Place: Kanpur

(Project Guide)

(Head of Department)
College Seal
DECLARATION

I hereby declare that the project titled “OTP Generator” is my original work and
has been carried out by me under the guidance of my faculty. This project has not
been submitted to any other institution or university for the award of any degree or
certificate.

All the information, data, and results presented in this report are true to the best of
my knowledge and belief. Any external sources used or referred to have been duly
acknowledged in the report

.
ACKNOWLEDGEMENT
I am grateful for the opportunity to work on this project, “OTP Generator,” which
has helped me enhance my technical skills and explore creative design approaches.
I would like to express my sincere gratitude to my faculty for their continuous
guidance, encouragement, and valuable feedback throughout the development of
this project.
Finally, I would like to thank my friends for their motivation and belief in my
abilities, which inspired me to complete this project successfully.
This project has been a great learning experience, helping me strengthen my
knowledge of HTML, CSS, JavaScript and python concepts.
INDEX

[Link]. Particulor Page No.


1. Introduction
1.1 Overview of OTP
1.2 Problem Statement
1.3 Objectives of the Project
1.4 Scope of the Project

2. System Analysis
2.1 Existing System
2.2 Proposed System
2.3 Feasibility Study
3. System Design & Technology Used
3.1 Technologies Used
3.2 Architecture / Block Diagram
3.3 Data Flow Diagram
4. Implementation
4.1 Code Explanation
4.2 OTP Generation Module
4.3 OTP Verification Module
5. Testing & Result
5.1 Test Cases
5.2 Test Results
5.3 Observations
6. Conclusion & Future Scope
6.1 Conclusion
6.2 Future Scope
7. 7. Bibliography
8. 8. Appendix
Introduction

1.1 Overview of OTP


An OTP (One Time Password) is a randomly generated numeric or alphanumeric
code used for user authentication. It provides an additional layer of security by
verifying the identity of the user during login, registration, or online transactions.
Unlike traditional passwords, which remain the same until changed, an OTP is valid
for a single use and expires after a short duration.
Nowadays, OTP systems are widely used in banking, email verification, mobile
applications, and online payment platforms to protect users from unauthorized
access.

1.2 Problem Statement


In traditional authentication systems, users rely only on static passwords. These
passwords can be easily guessed, reused, or stolen through hacking, phishing, or
data breaches. Because of this, only password-based authentication has become
unsafe and outdated.
There is a need for an additional, time-sensitive, and unique security layer that can
help verify the genuine user and prevent unauthorized logins.
The problem is to design a simple and secure mechanism that generates a one-
time, unpredictable code and verifies it within a limited timeframe.

1.3 Objectives of the Project

The main objectives of this project are:

 To design and develop a Python-based OTP generator system.


 To generate a unique, secure OTP using Python libraries.
 To verify the OTP entered by the user within a specific time limit.
 To provide a simple and user-friendly way of adding security to any login or
verification process.
 To understand and demonstrate the working of authentication systems in real-world
applications.

6
1.4 Scope of the Project

The scope of this project includes:

 Generating secure numeric or alphanumeric OTPs.


 Verifying OTP entered by the user.
 Checking time validity of the OTP.
 Displaying output messages based on correct, incorrect, or expired OTP.

What this project can be extended to:

 Sending OTP through email or SMS.


 Integrating the OTP system with login, signup, or password reset modules.
 Using graphical user interfaces (GUI) or mobile apps for better usability.

This project mainly focuses on the core mechanism of OTP generation and verification
using Python.

7
System Analysis
2.1 Existing System

In the existing authentication system, most applications rely only on a static username and
password for verification. This method has several weaknesses:

 Users often create weak or predictable passwords.


 Many users reuse the same password across multiple websites.
 Passwords can be stolen through hacking, phishing, or keylogging attacks.
 There is no additional security layer to confirm whether the real user is trying to log
in.

2.2 Proposed System

The proposed system introduces a Python-based OTP (One Time Password) verification
mechanism, which adds an extra level of security.

In this system:

 A unique OTP is generated each time the user attempts to authenticate.


 The OTP is valid only for one-time use and for a limited time period (e.g., 60
seconds).
 The user enters the OTP received/generated.
 The system verifies whether:
o The OTP matches, and
o The OTP is still within the valid time limit.

Advantages of the Proposed System

 Provides stronger security compared to traditional password-only systems.


 Prevents unauthorized access even if the password is leaked.
 Simple and easy to implement using Python.
 Can be integrated into login, signup, or transaction systems.

8
2.3 Feasibility Study

A feasibility study helps to determine whether the proposed project is practical and
implementable.

A. Technical Feasibility

The project is technically feasible because:

 It uses Python, which is easy to learn and widely supported.


 Required libraries like random, string, and time are built into Python.
 No advanced hardware or complex tools are required.
 Works across any operating system (Windows, Linux, Mac).

B. Economic Feasibility

The project is economically feasible because:

 Python is free and open-source.


 No paid tools, platforms, or servers are required.
 No additional hardware purchase is needed.
 The cost of development and maintenance is extremely low.

C. Operational Feasibility

Operationally, the system is easy to use and understand:

 The interface is simple (console-based).


 Users can easily enter and verify the OTP.
 The system gives clear messages for ―correct‖, ―incorrect‖, or ―expired‖ OTP.
 Minimal training is needed for end user

9
3. System Design & Technology Used

3.1 Technologies Used (content)

Programming Language: Python 3.x

Libraries / Modules:

 random — for secure/random selection of digits/characters


 string — for digits/letters (if alphanumeric OTP)
 time / datetime — to record generation time & expiry logic
 hashlib (optional) — for hashing OTP before storing (extra security)
 smtplib / email (optional) — to send OTP by email
 requests / SMS-gateway SDK (optional) — to send OTP by SMS

Tools / IDE: VS Code / PyCharm / IDLE


Platform: Windows / Linux / macOS (cross-platform)

Design Decisions (short):

 OTP length configurable (usually 4–6 digits).


 OTP expiry set (e.g., 60 seconds).
 Store OTP temporarily in memory (or cache like Redis for production).
 Use TOTP or hashing for stronger security in future.

3.2 Architecture
User Login Page

User summit valid user id and password

OTP Genteration

User is
User enters valid
Authenticated
OTP

1
0
Implementation
4.1 Code Explanation

Overview:
The implementation is divided into small, reusable functions:

 generate_otp(length) — creates a random OTP string of given length.


 store_otp(key, otp, ttl) — stores OTP in temporary in-memory store with timestamp
(TTL = expiry seconds).
 send_otp(destination, otp) — placeholder to send OTP (console/email/SMS). For the
mini project we print to console; in real systems integrate SMTP or SMS API.
 verify_otp(key, entered_otp) — checks whether OTP exists, is not expired, and
matches the entered value.

4.2 OTP Generation Module

Purpose: Create a secure, random OTP and store it with a timestamp.

Functions & Behavior

 generate_otp(length=6, alpha=False)
o Inputs: length (int), alpha (bool — include letters if True)
o Process: choose characters from [Link] or string.ascii_letters + digits and
build OTP.
o Output: OTP string.
 store_otp(store, key, otp)
o Inputs: store (dict), key (e.g., username or session id), otp (string)
o Process: records (otp, generation_time) in the store.
o Output: None (mutates store).
 send_otp(destination, otp)
o For mini project: prints the OTP to console (simulate sending).
o For production: integrate with smtplib or SMS API.

1
1
4.3 OTP Verification Module
Purpose: Verify user-submitted OTP against the stored OTP and expiry time.

Functions & Behavior

 is_otp_expired(gen_time, ttl=DEFAULT_TTL)
o Checks elapsed time against TTL.
 verify_otp(store, key, entered_otp, ttl=DEFAULT_TTL)
o Steps:
1. Check whether an OTP exists for key. If not → return "NO_OTP".
2. If exists, check expiry: if expired → delete entry and return "EXPIRED".
3. If not expired, compare entered_otp with stored OTP:
 If match → delete entry and return "SUCCESS".
 Else → return "INVALID" (do not delete on invalid so user can
retry until TTL).

1
2
Testing
5.1 Test Cases

Testing ensures that the OTP system works correctly under different input conditions.
The following table summarises the major test cases performed on the system:

Test Case Table (You will add screenshot of this table if needed)
Test Actual
Description Input Expected Output Status
Case ID Output
As
TC01 Generate 6-digit OTP Request OTP OTP of 6 digits Pass
expected
Enter correct OTP within ―OTP Verified / As
TC02 Correct OTP Pass
time Access Granted‖ expected
As
TC03 Enter incorrect OTP Wrong OTP ―Invalid OTP‖ Pass
expected
OTP expired after 60 Delay > 60 As
TC04 ―OTP Expired‖ Pass
seconds seconds expected
No OTP generated but ―No OTP Found / As
TC05 Enter OTP Pass
verification attempted Request again‖ expected
OTP should be unique per Multiple Different OTP each As
TC06 Pass
request requests time expected
Length = 4 or OTP should follow As
TC07 OTP length change test Pass
6 selected length expected

5.2 Test Results

Based on the above test cases, the test results were recorded as follows:

 The OTP was generated successfully with the correct length (4 or 6 digits).
 The system correctly validates the OTP when the input matches the generated code.
 The system identifies incorrect OTP entries and displays the appropriate message.
 OTP expiry function works accurately after the predefined time limit (60 seconds).
 Only one OTP remains active at a time for a user/session.
 The system is stable and responds instantly, demonstrating good performance.
 No critical bugs or errors were found during testing.

1
3
Overall Result:
✔ All major functional test cases passed successfully.

5.3 Observations

During the testing of the Python-based OTP system, the following observations were made:

 OTP generation is random and secure because it uses Python’s built-in random
module.
 Execution time is very fast; generating and verifying OTP takes less than 1
millisecond.
 The expiry-time mechanism works correctly and prevents old OTPs from being
reused.
 The program handles common error conditions properly such as:
o expired OTP
o invalid OTP
o verification without prior OTP generation
 The user interface (console-based) is simple and easy to understand.
 The system can be easily extended to email or SMS verification by adding additional
modules.

General Observation:
The OTP system is reliable, lightweight, and suitable for small applications requiring
additional security.

1
4
31
5

You might also like