Skip to content
forked from gwwfps/onetime

An one-time password generation library written in Go, implementing HOTP (RFC-4226) and TOTP (RFC-6238).

License

Notifications You must be signed in to change notification settings

dchapes/onetime

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

onetime

An one-time password generation library written in Go, implementing HOTP (RFC-4226) and TOTP (RFC-6238).

Example usage

Simple 6-digit HOTP code:

import "onetime"

var secret = []byte("SOME_SECRET")
var counter = 123456
var otp, _ = onetime.Simple(6)
var code = otp.HOTP(secret, counter)

Google authenticator style 8-digit TOTP code:

import "onetime"

var secret = []byte("SOME_SECRET")
var otp, _ = onetime.Simple(8)
var code = otp.TOTP(secret)

9-digit 5-second-step TOTP starting on midnight 2000-01-01 UTC, using SHA-256:

import (
    "crypto/sha256"
    "onetime"
    "time"
)

var secret = []byte("SOME_SECRET")
const ts = 5 * time.Second
var t = time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC)
var otp = onetime.OneTimePassword{Digit: 9, TimeStep: ts, BaseTime: t, Hash: sha256.New}
var code = otp.TOTP(secret)

Documentation

Package doc can be found at godoc.org.

License

This library is released under a simplified BSD license.

About

An one-time password generation library written in Go, implementing HOTP (RFC-4226) and TOTP (RFC-6238).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%