otp

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2020 License: MIT Imports: 9 Imported by: 0

README

One Time Pass

This one time token generator is based off RFC 4226 and generates tokens based on a shared secret and the time interval.

Variables

  • Interval - default 30-seconds
  • Entropy - number of bytes for Secret; default 20

Functions

  • Sizer - specify the number of digits to emit; default 6
  • Secret - random secret generator; eg. AW6TJVTYMAYJXLWFW2WWJ6D3Q5B2AY25
  • HOTPToken - generation requires a secret and an interval timeframe
  • Token - is a HOTPToken with current Interval seed
  • Tokens - is a HOTPToken with a bracketed last|now|next current Interval seed range

func main() {

  secret := "secretsecretsecret"

  fmt.Println(otp.Token(secret))  // 397657
  fmt.Println(otp.Tokens(secret)) // [755604 397657 140422]

  otp.Sizer(10)

  fmt.Println(otp.Token(secret))  // 1545628642
  fmt.Println(otp.Tokens(secret)) // [0511092633 1545628642 1383583942]
  
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Entropy = 20

Entropy bytes for Secret generation; default 20

View Source
var Interval = time.Second * 30

Interval timeframe; default 30-second

Functions

func HOTPToken

func HOTPToken(secret string, interval int64) string

HOTPToken generation requires a secret and a timeframe interval

func Secret

func Secret() string

Secret generator; default 20 Entropy bytes eg. AW6TJVTYMAYJXLWFW2WWJ6D3Q5B2AY25

func Sizer

func Sizer(n int)

Sizer configures the package level otp digit size; default 6

func Token

func Token(secret string) string

Token is a HOTPToken with an Interval seed

func Tokens

func Tokens(secret string) [3]string

Tokens is a HOTPToken with a bracketed [last|now|next] Interval seed range

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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