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 Nov 18

A message from Iran, asking for help on creating better proxies

Nazmul Hossain profile image
JavaScript Developer

😓 Sore eyes?

dev.to now has a dark version (in public beta).

Go to the "misc" section of your settings and select night theme ❤️