totp

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2017 License: MIT Imports: 10 Imported by: 0

README

Time-based One-Time Password algorithm (TOTP).

Generate secrets, generate codes, and validate codes. Compatible with Google Authenticator.

Installation

This package can be installed with the go get command:

go get github.com/nathanwinther/totp

Usage

package main

import (
  "fmt"
  "github.com/nathanwinther/totp"
)

func main() {
  secret, err := totp.CreateSecret(16)
  if err != nil {
    panic(err)
  }
  fmt.Println(secret)
  code, err := totp.GetCode(secret)
  if err != nil {
    panic(err)
  }
  fmt.Println(code)
  fmt.Println(totp.VerifyCode(secret, code, 2))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateSecret

func CreateSecret(size int) (string, error)

func GetCode

func GetCode(secret string) (string, error)

func VerifyCode

func VerifyCode(secret string, code string, drift int) bool

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL