utils

package
v1.2210.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: MPL-2.0 Imports: 15 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 Md5 added in v1.2209.0

func Md5(src string) string

func Md5String

func Md5String(data string) string

func NewEncryptor added in v1.2206.0

func NewEncryptor(key []byte) *encryptor

func NvlString added in v1.2208.0

func NvlString(param *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 RemoveDuplicateUint added in v1.2209.0

func RemoveDuplicateUint(c []uint) []uint

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

func SupplementalQuotationMarks added in v1.2205.0

func SupplementalQuotationMarks(s string) string

If there are no quotation marks (', ", `) at the beginning and end of the string, the string will be wrapped with "`" Need to be wary of the presence of "`" in the string do nothing if s is an empty string

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