auth

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package auth provides password hashing and verification.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateTOTPCode added in v0.11.0

func GenerateTOTPCode(secret string) string

GenerateTOTPCode generates the current TOTP code for a given secret.

func GenerateTOTPSecret added in v0.10.0

func GenerateTOTPSecret() (string, error)

GenerateTOTPSecret generates a random base32-encoded TOTP secret (160 bits).

func GenerateTOTPURI added in v0.10.0

func GenerateTOTPURI(secret, issuer, accountName string) string

GenerateTOTPURI builds an otpauth:// URI for use with authenticator apps.

func HashPassword

func HashPassword(password string) (string, error)

HashPassword hashes a plaintext password using bcrypt with a cost of 10.

func ValidateTOTP added in v0.10.0

func ValidateTOTP(secret, code string) bool

ValidateTOTP checks a 6-digit code against a TOTP secret. Checks current, previous, and next time step to allow for clock drift.

func VerifyPassword

func VerifyPassword(hash, password string) bool

VerifyPassword compares a plaintext password against a bcrypt hash. Returns true if the password matches the hash.

Types

This section is empty.

Jump to

Keyboard shortcuts

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