otp

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultBcryptCost = 12

DefaultBcryptCost is the cost used for hashing OTPs.

Variables

This section is empty.

Functions

func Generate

func Generate() (string, string, error)

Generate produces a cryptographically random 6-digit code and its bcrypt hash. The caller must send `plain` to the user and persist `hash` in the database. The plain-text code must never be stored.

func GenerateWithCost

func GenerateWithCost(cost int) (string, string, error)

GenerateWithCost produces a cryptographically random 6-digit code and its bcrypt hash with a custom cost.

func Verify

func Verify(plain, hash string) error

Verify returns nil if plain matches the stored bcrypt hash, or an error otherwise.

Types

This section is empty.

Jump to

Keyboard shortcuts

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