utils

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var JwtKey string

Functions

func ComparePwd

func ComparePwd(pwd string, hash string) bool

ComparePwd 比较密码密文与明文是否相等

func EncodePWD

func EncodePWD(pwd string) (string, error)

EncodePWD 密码加密

func ErrorCode

func ErrorCode(ctx *context.Context, code int, err error)

func ErrorStr

func ErrorStr(ctx *context.Context, err string)

func Errore

func Errore(ctx *context.Context, err error)

func FormatBytes

func FormatBytes(c uint64) string

func FormatBytesSpeed

func FormatBytesSpeed(c uint64) string

func FormatDay

func FormatDay(sec uint64) string

func FormatDuration

func FormatDuration(d time.Duration) string

func FormatPercent

func FormatPercent(numerator uint64, denominator uint64) string

func FormatSeconds

func FormatSeconds(sec uint64) string

func Get

func Get(key string) (interface{}, bool)

func GetCurUser

func GetCurUser(ctx *context.Context) *model.Userinfo

func GetJwtVerifier

func GetJwtVerifier() *jwt.Verifier

func GetSN

func GetSN() string

GetSN 获取机器序列号

func GetToken

func GetToken(data interface{}) (*model.TokenInfo, error)

func GetTokenExpires

func GetTokenExpires(ctx *context.Context) time.Time

func InitJwt

func InitJwt()

func Len

func Len() int

func RandomString

func RandomString(length int) string

* 生成随机字符串

func Set

func Set(key string, data interface{}, timeout int)

func SetIV

func SetIV(data []byte)

func Sm2GenerateKey

func Sm2GenerateKey(pwd string) (prikey []byte, pubKey []byte, err error)

func Sm2ReadCertificateFromPem

func Sm2ReadCertificateFromPem(cert []byte) *x509.Certificate

func Sm2ReadCertificateRequestFromPem

func Sm2ReadCertificateRequestFromPem(cert []byte) *x509.CertificateRequest

func Sm2ReadPrivateKeyFromPem

func Sm2ReadPrivateKeyFromPem(key []byte, pwd string) *sm2.PrivateKey

func Sm2ReadPublicKeyFromPem

func Sm2ReadPublicKeyFromPem(key []byte) *sm2.PublicKey

func Sm3

func Sm3(data []byte) []byte

Sm3 加密

func Sm3Hash

func Sm3Hash() hash.Hash

func Sm4Decrypt

func Sm4Decrypt(key string, sec string) string

Sm4Decrypt 解密

func Sm4Encrypt

func Sm4Encrypt(key string, data string) string

Sm4Encrypt 加密

func ToJSONString

func ToJSONString(status interface{}) string

这个函数接受一个接口作为参数并返回一个字符串

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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