Skip to content
/ oath Public

TOTP generator and validator. Wrapper for liboath C library.

Notifications You must be signed in to change notification settings

tapir/oath

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

oath

  • oath is a light wrapper for liboath library from oath-toolkit project.
  • Currently, only TOTP generation and validation functions are implemented.
  • See godoc for documentation.

Example

package main

import (
	"fmt"
	"oath"
)

func main() {
	// Init library
	oath.Init()
	defer oath.Done()

	secret := "ABCDEFGHJKLMNOPR"

	// Generate a 6 digit OTP for 30 second time step.
	otp, err := oath.TOTPGenerate(secret, 30, 6)
	if err != nil {
		panic(err)
	}
	fmt.Println(otp)

	// Validate the OTP with 1 time step tolerance
	r, err := oath.TOTPValidate(secret, 30, 1, otp)
	if err != nil {
		panic(err)
	}
	fmt.Println(r) // Should print true
}

About

TOTP generator and validator. Wrapper for liboath C library.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages