secret

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package secret mints and compares one-time secrets over crypto/rand: tokens, numeric and alphabet codes, their stored digests and constant-time comparison. Every secret AuthKit issues comes from here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Code

func Code(n int, alphabet string) string

Code returns n characters drawn uniformly from alphabet (single-byte characters). crypto/rand.Int samples by rejection, so no character is favored whatever the alphabet's size.

func Digits

func Digits(n int) string

Digits returns an n-digit decimal code; leading zeros are kept.

func Equal

func Equal[T ~string | ~[]byte](a, b T) bool

Equal compares two secrets, or their digests, in constant time; differing lengths compare unequal. Every secret comparison goes through it.

func Hash

func Hash(s string) string

Hash is the stored form of a one-time secret: its hex SHA-256.

func Token

func Token(n int) string

Token returns n random bytes as unpadded URL-safe base64.

Types

This section is empty.

Jump to

Keyboard shortcuts

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