Help us shape the future of Go! Take the 2026 Go Developer Survey

hmac

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0, Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RandomBytes

func RandomBytes(n int) ([]byte, error)

RandomBytes returns n random bytes by reading from crypto/rand.Reader

Types

type HMACStrategy

type HMACStrategy struct {
	sync.Mutex
	Config HMACStrategyConfigurator
}

HMACStrategy is responsible for generating and validating challenges.

func (*HMACStrategy) Generate

func (c *HMACStrategy) Generate(ctx context.Context) (string, string, error)

Generate generates a token and a matching signature or returns an error. This method implements rfc6819 Section 5.1.4.2.2: Use High Entropy for Secrets.

func (*HMACStrategy) Signature

func (*HMACStrategy) Signature(token string) string

func (*HMACStrategy) Validate

func (c *HMACStrategy) Validate(ctx context.Context, token string) (err error)

Validate validates a token and returns its signature or an error if the token is not valid.

Jump to

Keyboard shortcuts

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