otp

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package provides an implementation to generate one-time password values based on the TOTP (Time-Based One-Time Password) and HOTP (HMAC-Based One-Time Password) algorithms as defined into the RFC4226 and RFC6238 specifications

Index

Constants

View Source
const (
	DefaultInterval = 30
	DefaultDigits   = 6
)

Variables

This section is empty.

Functions

func HOTP

func HOTP(h func() hash.Hash, key []byte, count uint64, digits int) (string, error)

HOTP generates an HOTP (HMAC-Based One-Time Password) value as defined into the RFC4226 Note: if the hash function is nil, defaults to SHA1 Reference: https://datatracker.ietf.org/doc/html/rfc4226

func TOTP

func TOTP(h func() hash.Hash, key []byte, t time.Time, interval int, digits int) (string, error)

TOTP generates a TOTP (Time-Based One-Time Password) value as defined into the RFC6238 Note: if the hash function is nil, defaults to SHA1 Reference: https://datatracker.ietf.org/doc/html/rfc6238

func TOTPFromBase32 added in v0.22.0

func TOTPFromBase32(h func() hash.Hash, decodedKey string, t time.Time, interval int, digits int) (string, error)

TOTPFromBase32 generates a TOTP (Time-Based One-Time Password) value as defined into the RFC6238 from a base32 encoded secret

Types

This section is empty.

Jump to

Keyboard shortcuts

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