package otc

import "git.sr.ht/~pingoo/stdx/otc"

package otc provides alphanumeric One Time Codes that can be used for email-based 2FA, account verification and more.

Index

Variables

var (
	ErrTokenIsNotValid = errors.New("otc: token is not valid")
)

Functions

func Verify

func Verify(code, token string) bool

Types

type Code

type Code struct {
	// contains filtered or unexported fields
}

func New

func New(length uint16) (code Code, err error)

func (*Code) Code

func (code *Code) Code() string

func (*Code) CodeHTML

func (code *Code) CodeHTML() (ret string)

CodeHTML returns the code wrapped in a <span> and with numbers wrapped in <span style="color: red">

func (*Code) Token

func (code *Code) Token() string

Token returns a token of the form otc.v[N].[XXXX] where [N] is the version number of the token and [XXXX] is Base64URL encoded data The token should be stored in a database or a similar secure place and use it later to verify that a code is valid

type NewCodeOptions

type NewCodeOptions struct {
}

Source Files

otc.go

Version
v0.0.0-20240218134121-094174641f6e (latest)
Published
Feb 18, 2024
Platform
linux/amd64
Imports
7 packages
Last checked
4 months ago

Tools for package owners.