crypto

package
v0.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
View Source
const DIGIT_CHARS = "0123456789"
View Source
const LEN_CHARS = len(CHARS)
View Source
const LEN_DIGIT_CHARS = len(DIGIT_CHARS)

Variables

This section is empty.

Functions

func RandomBytes

func RandomBytes(nbytes int) []byte

RandomBytes returns a random byte slice of the given length.

func RandomDigits

func RandomDigits(nchars int) string

func RandomString

func RandomString(nchars int) string

RandomString returns a random string of the given length.

Types

type Auth

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

func NewAuth

func NewAuth(secret []byte) *Auth

NewAuth creates a new Auth instance.

func (*Auth) GenerateToken

func (a *Auth) GenerateToken(sub string, aud string, exp time.Time) (string, error)

GenerateToken generates a new JWT token.

func (*Auth) ValidateToken

func (a *Auth) ValidateToken(token string, aud string) (string, time.Time, error)

ValidateToken validates a JWT token.

Jump to

Keyboard shortcuts

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