utils

package
v1.2204.0-pre1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2022 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var JWTSecretKey = []byte("secret")
View Source
var SecretKey = []byte("471F77D078C5994BD06B65B8B5B1935B")

Functions

func AddDelTag

func AddDelTag(delTime *time.Time, target string) string

func AesDecrypt

func AesDecrypt(encrypted string) (string, error)

func AesEncrypt

func AesEncrypt(origData string) (string, error)

func DecodeString

func DecodeString(base64Str string) (string, error)

func GetDuplicate

func GetDuplicate(c []string) []string

func HasPrefix

func HasPrefix(s, prefix string, caseSensitive bool) bool

func HasSuffix

func HasSuffix(s, suffix string, caseSensitive bool) bool

func JoinUintSliceToString added in v1.2202.0

func JoinUintSliceToString(s []uint, sep string) string

sep example: ", "

func Md5String

func Md5String(data string) string

func ParseAuditPlanName

func ParseAuditPlanName(tokenString string) (string, error)

ParseAuditPlanName used by echo middleware which only verify api request to audit plan related.

func RemoveDuplicate

func RemoveDuplicate(c []string) []string

func Round

func Round(f float64, dec int) float64

Round rounds the argument f to dec decimal places.

func SetSecretKey added in v1.2203.0

func SetSecretKey(key []byte) error

Types

type CustomClaimOption

type CustomClaimOption interface {
	// contains filtered or unexported methods
}

func WithAuditPlanName

func WithAuditPlanName(name string) CustomClaimOption

type JWT

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

func NewJWT

func NewJWT(signingKey []byte) *JWT

func (*JWT) CreateToken

func (j *JWT) CreateToken(userName string, expireUnix int64, customClaims ...CustomClaimOption) (string, error)

type Password

type Password string

func (*Password) MarshalJSON

func (p *Password) MarshalJSON() ([]byte, error)

Jump to

Keyboard shortcuts

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