• We've moved. Our community is now at ownd.sh — latest discussions and updates live there.

☘️ How to Verify OTP using Python ☘️ Create an application for OTP Verification ☘️

WhiteyBay

Contributor
Contributor
Rep
0
0
0
Rep
126
Vouches
0
0
0
Vouches
0
Posts
3,255
Likes
2,319
Bits
5 YEARS
5 YEARS OF SERVICE
This Thread is Sponsored by this Venerable!

Wake Up to the Reality!

Learn and Level Up with U
demy.

Check 

u1 u2 u3

 

Do you know how you get a unique OTP every time you go through the payment process in an online transaction? Each company has its ways of creating an OTP for verification, but most of the companies have

their systems programmed to generate a 6-digit random number. In this article, I will walk you through the task of OTP verification using Python. By the end of this article, you will be able to send a unique OTP

to any email id for the OTP verification task.

 

 If it HELPS you

 

☯ LIKE | +REP | Vouch | Rate | SUPPORT ☮

 

 

Hidden Content

 

sheepe.gifPSAshrug.gif

limited time Offer

Get before it's gone!

Hit Like heart5.png   Add Reputation yes2.png  Rate PepoThink.png 

I don't want to waste my time

pissed.gif Reporting and Banning You! ban.gif


 

wooow.png Check out my other threads also evilrondo.png

☯ More Incomming! ☮


 

 

 
Show ContentSpoiler:

Steps to Create an OTP Verification System using Python

OTP Verification is the process of verifying a user by sending a unique

password so that the user can be verified before completing a

registration or payment process. Most of the time, we get an OTP when

we make an online payment, or when we forget our password, or when

creating an account on any online platform. Thus, the sole purpose of

an OTP is to verify the identity of a user by sending a unique password.

We can easily create an application for the task of OTP verification

using Python by following the steps mentioned below:

1. First, create a 6-digit random number

2. Then store the number in a variable

3. Then we need to write a program to send emails

4. When sending email, we need to use OTP as a message

5. Finally, we need to request two user inputs; first for the

user’s email and then for the OTP that the user has received.

So this is the complete process of creating an OTP verification

application using Python. In the section below, I will take you through

how to implement these steps using Python for the task of OTP

verification.

OTP Verification using Python

I hope you now have understood what is an OTP and how we can create

an application for the task of OTP verification. Now let’s follow the

steps mentioned above by using Python to create an application for the

task of OTP verification. I will start by importing the necessary Python

library that we need for this task:

import os

import math

import random

import smtplib

Now I will generate a random number and store it in a variable which I will be using while sending emails to the users:

digits="0123456789"

OTP=""

for i in range(6):

 OTP +=digits[math.floor(random.random()*10)]

 otp = OTP + " is your OTP"

 msg= otp

Now, before we go ahead, you need to have your Google app password

to be able to send emails using your Gmail account. After you create your app

password for your Gmail account you will get a key. Copy that key and

paste in the code below to send emails for OTP verification using Python:

s = smtplib.SMTP('smtp.gmail.com', 587)

s.starttls()

s.login("Your Gmail Account", "You app password")

emailid = input("Enter your email: ")

s.sendmail('&&&&&&&&&&&',emailid,msg)

a = input("Enter Your OTP >>: ")

if a == OTP:

 print("Verified")

else:

 print("Please Check your OTP again")

Enter your email: [email protected]

Enter Your OTP >>: 478348

Verified

Once you run this code you enter an email where you want to send an OTP and then enter the OTP that you have received in the email. You can get the complete code used in this article for the task of OTP verification from below.

import os

import math

import random

import smtplib

digits="0123456789"

OTP=""

for i in range(6):

OTP

+=digits[math.floor(random.random()*10)]

otp = OTP + " is your OTP"

msg= otp

s = smtplib.SMTP('smtp.gmail.com', 587)

s.starttls()

s.login("Your Gmail Account", "You app password")

emailid = input("Enter your email: ")

s.sendmail('&&&&&&&&&&&',emailid,msg)

a = input("Enter Your OTP >>: ")

if a == OTP:

 print("Verified")

else:

 print("Please Check your OTP again")

 

 



 

Attachments

  • sheepe.gif
    sheepe.gif
    4.5 KB · Views: 0
  • shrug.gif
    shrug.gif
    12.5 KB · Views: 1
  • heart5.png
    heart5.png
    380 bytes · Views: 1
  • yes2.png
    yes2.png
    768 bytes · Views: 3
  • PepoThink.png
    PepoThink.png
    684 bytes · Views: 1
  • pissed.gif
    pissed.gif
    1.8 KB · Views: 1
  • ban.gif
    ban.gif
    10.8 KB · Views: 3
  • wooow.png
    wooow.png
    730 bytes · Views: 3
  • evilrondo.png
    evilrondo.png
    744 bytes · Views: 0

shamed3sw

Active member
shamed3sw Rep
0
0
Rep
0
shamed3sw Vouches
0
0
0
Vouches
0
Posts
59
Likes
0
Bits
1 YEAR
1 YEAR OF SERVICE
let me seee
 

Ankahub

Honorary Member
Ankahub Rep
0
0
Rep
0
Ankahub Vouches
0
0
0
Vouches
0
Posts
263
Likes
3
Bits
1 YEAR
1 YEAR OF SERVICE

washedw

Member
washedw Rep
0
0
Rep
0
washedw Vouches
0
0
0
Vouches
0
Posts
47
Likes
0
Bits
1 YEAR
1 YEAR OF SERVICE

juginbalenci

Well-known member
juginbalenci Rep
0
0
Rep
0
juginbalenci Vouches
0
0
0
Vouches
0
Posts
157
Likes
0
Bits
1 YEAR
1 YEAR OF SERVICE
[font]thank you[/font]
 

179,162

126,023

1,405,739

Top