OTP Verification using Hash

twitter logo github logo ・1 min read

Most of the time cache memory or database used to verify OTP. It's expensive operation. We can verify OTP without using database or cache memory.

Today I will explain how to verify OTP without cache memory/ database operation.

OTP requested user send request with mobile number. Then requested number, generated OTP(using otp-generator) is used to create hash value using sha256. Then hash value is used for OTP request response & preserve it on frontend. Generated OTP will send to requested users Mobile number.

After getting OTP, user now verify OTP with 2nd request. On the 2nd request OTP, Mobile No & Hash will be sent to the server to verify. Using mobile no & OTP we will generate new hash. New hash value will be compared with requested hash value. If both hash value matched then OTP is verified.

Code: https://github.com/bilashcse/otp-verification

twitter logo DISCUSS
Classic DEV Post from Mar 20

JavaScript predictions for 2019 by npm

npm, Inc., which runs the world’s biggest software registry has shared some very interesting read about insights and predictions about JavaScript for 2019

Nazmul Hossain profile image
JavaScript Developer
DEV.join()

Come for the ideas.
Stay for the community.