Skip to content

A Go package to generate and validate OTP(One-Time-Password) .

Notifications You must be signed in to change notification settings

seyiadel/otp-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OTP-Generator

This Go package is to generate One-Time Password for Email based Accoounts

Usage

In your development environment,
  • Install OTP-Go: go get github.com/seyiadel/otp-go/otp
  • Import and run go mod tidy
Gorm(Go object relational mapper) is being added during installation so as to create any database of your choice to save arguments/keyword arguments. Import Gormimport ("gorm.io/gorm) and gorm driver import "gorm.io/driver/sqlite" for your preferred database. Check Gorm.io driver. For Example using sqlite database and driver,

conn, err := gorm.Open(sqlite.Open("test.db"), &gorm.Config{}) if err != nil{ panic("failed to connect to database") }

Now you can call the package methods to validate and generate OTP.

otp.Generate(conn,"[email protected]", 4) as conn is the database, [email protected] is the user email, 4 is the desired otp length

otp.ValidateOTP(conn, "[email protected]", 7645)as conn is the database, [email protected] is the user email, 7645 is the token generated

Hurrayyyy!🤩🤩

About

A Go package to generate and validate OTP(One-Time-Password) .

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages