Skip to content

TOTP is a Time Based OTP library in golang for server side and client side both.

License

Notifications You must be signed in to change notification settings

tech-thinker/totp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TOTP

GitHub release (latest by date) GitHub Workflow Status GitHub GitHub last commit GitHub forks GitHub top language

TOTP is a Time Based One Time Password Algorithm, which can be used in client side or server side applications.

Features

  • Generate TOTP secret.
  • Generate TOTP code.
  • Verify TOTP code.

How to use it?

  • Install dependencies
go get github.com/tech-thinker/totp@v1.0.0
  • Write your code
package main    You, 05/11/24 09:52initial commit

import (
    "fmt"

    "github.com/tech-thinker/totp"
)

func main() {
    secret, err := totp.GenerateSecret()
    if err != nil {
        fmt.Println("Error generating secret:", err)
    }
    duration := 30
    otp, err := totp.TOTP(secret, duration)
    if err != nil {
        fmt.Println("Error generating TOTP:", err)
        return
    }
    fmt.Println("Generated TOTP Code:", otp)
    fmt.Println("Verify:", totp.Validate(secret, duration, otp))
}

Contributors

About

TOTP is a Time Based OTP library in golang for server side and client side both.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages