Skip to content

Latest commit

 

History

History
49 lines (41 loc) · 1.39 KB

README.md

File metadata and controls

49 lines (41 loc) · 1.39 KB

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/[email protected]
  • 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