utils

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base32Decode

func Base32Decode(value string) ([]byte, error)

func Base32Encode

func Base32Encode(value []byte) string

func Base32NoPaddingDecode

func Base32NoPaddingDecode(value string) ([]byte, error)

func Base64Decode

func Base64Decode(value string) ([]byte, error)

func Base64Encode

func Base64Encode(value []byte) string

func Base64NoPaddingDecode

func Base64NoPaddingDecode(value string) ([]byte, error)

func Base64URLDecode

func Base64URLDecode(value string) ([]byte, error)

func Base64URLEncode

func Base64URLEncode(value []byte) string

func Base64URLNoPaddingDecode

func Base64URLNoPaddingDecode(value string) ([]byte, error)

func CreateJWT

func CreateJWT(params JWTParams) (string, error)

func Decrypt

func Decrypt(value []byte, passPhrase []byte) ([]byte, error)

func DecryptAndVerify

func DecryptAndVerify(value []byte, passPhrase []byte, hash []byte) ([]byte, error)

func Encrypt

func Encrypt(value []byte, passPhrase []byte) ([]byte, error)

func EncryptWithHash

func EncryptWithHash(value []byte, passPhrase []byte) ([]byte, []byte, error)

func ExtractInfoFromJWT

func ExtractInfoFromJWT(jwtString string) (*jwt.StandardClaims, error)

func GenerateQRCodeImage added in v0.3.0

func GenerateQRCodeImage(data string, size int) ([]byte, error)

func GetPrettyJSON

func GetPrettyJSON(v interface{}) ([]byte, error)

func MinifyJSON

func MinifyJSON(str string) ([]byte, error)

func NetworkContainsIP

func NetworkContainsIP(network string, ip string) (bool, error)

func ParseJWT

func ParseJWT(jwtString string, params JWTParams) (*jwt.StandardClaims, error)

func PrettifyJSON

func PrettifyJSON(str string) ([]byte, error)

func RandomBytes

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

func ReadQRCodeImage added in v0.3.0

func ReadQRCodeImage(data []byte) (string, error)

func Sha256Compare

func Sha256Compare(value []byte, hash []byte) bool

func Sha256Hash

func Sha256Hash(value []byte) []byte

func ValidJSON

func ValidJSON(str string) error

func ValidateJWT

func ValidateJWT(jwtString string, issuer string, secret []byte) error

Types

type JWTInfo

type JWTInfo struct {
	Subject   string
	Issuer    string
	IssuedAt  time.Time
	ExpiresAt time.Time
}

type JWTParams

type JWTParams struct {
	Scope     string
	Subject   string
	Issuer    string
	Secret    []byte
	ExpiresAt time.Time
}

Jump to

Keyboard shortcuts

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