otpgen

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2021 License: MIT Imports: 12 Imported by: 0

README

otpgen

Library to generate TOTP/HOTP codes

Documentation

Overview

Package otpgen implements functions to generate TOTP/HOTP codes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HOTP

type HOTP struct {
	Secret  string // Secret key (required)
	Digits  int    //OTP digit count (default: 6)
	Counter int64  // Counter value (default: 0)
}

HOTP represents HMAC-Based One-Time Password Algorithm See https://datatracker.ietf.org/doc/html/rfc4226

func (*HOTP) Generate

func (hotp *HOTP) Generate() (string, error)

Generates HOTP code and returns OTP as string and any error encountered.

type TOTP

type TOTP struct {
	Secret    string // Secret key (required)
	Digits    int    // OTP digit count (default: 6)
	Algorithm string // OTP Algorithm ("SHA1" or "SHA256" or "SHA512")
	Period    int64  // Period for which OTP is valid (seconds) (default: 30)
	UnixTime  int64  // (Optional) Unix Timestamp (default: Current unix timestamp)
}

TOTP represents Time-based OTP. See https://datatracker.ietf.org/doc/html/rfc6238

func (*TOTP) Generate

func (totp *TOTP) Generate() (string, error)

Generates TOTP code and returns OTP as string and any error encountered.

Jump to

Keyboard shortcuts

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