cryptography

package
v0.0.0-...-37e2b78 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RegexEncodedHash          = regexp.MustCompile(`\$argon2id\$v=(\d+)\$m=(\d+),t=(\d+),p=(\d+)\$([A-Za-z0-9+/=]+)\$([A-Za-z0-9+/=]+)`)
	ErrorInvalidHashEncoding  = errors.New("hash does not have a valid encoding")
	ErrorInvalidArgon2Version = errors.New("invalid argon2 version")
)
View Source
var ErrorHashAndPasswordDoNotMatch = errors.New("hash and password do not match")

Functions

func CompareHashAndPassword

func CompareHashAndPassword(encodedHash, password string) error

func CreateJWT

func CreateJWT(key []byte, claims jwt.MapClaims) (string, error)

func Decrypt

func Decrypt(key, data []byte) (string, error)

func Encrypt

func Encrypt(key, data []byte) ([]byte, error)

func HashPassword

func HashPassword(password string, parameter Argon2IDParameter) (string, error)

func ValidateJWT

func ValidateJWT(key []byte, signedToken string) (jwt.MapClaims, error)

Types

type Argon2IDParameter

type Argon2IDParameter struct {
	SaltSize   int
	Iterations uint32
	Memory     uint32
	Threads    uint8
	KeyLength  uint32
}

Jump to

Keyboard shortcuts

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