ximi

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Sm2XimiPrivateKey = "" /* 340-byte string literal not displayed */
	Sm2XimiPublicKey  = "MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEX/ExHas7FvcW0G+E8ChaXoO16CwAMFb6gMn8bu97dHTjHKSTOIGbfDn0aE+eoJkU36BTtwWXgH3hvzVm4VCXog=="
)
View Source
const (
	// ContentTypeApplicationJson /*Content-Types*/
	ContentTypeApplicationJson = "application/json;charset=UTF-8"
	ContentTypeFormUrlEncoded  = "application/x-www-form-urlencoded"
	ContentTypeFormData        = "multipart/form-data"

	// StatusSuccess Business Status
	StatusSuccess = 0
	StatusFail    = -1

	// HttpHeaderXimiAccessToken http头
	HttpHeaderXimiAccessToken = "X-Access-Token"

	// RedisIdCacheKey Redis分布式ID
	RedisIdCacheKey = "GO:GLOBAL:FACTOR"
)

Variables

View Source
var IsCheckingLicense bool = false
View Source
var PrivateKey []byte
View Source
var PublicKey []byte

Functions

func DesDecode

func DesDecode(src string, key string) []byte

DesDecode Des解密

func DesEncode

func DesEncode(src []byte, key string) string

DesEncode Des加密

func GetMacs

func GetMacs(isSimple bool) (macAddrs []string, err error)

GetMacs 获取MAC地址

func HmacSHA1Base64

func HmacSHA1Base64(key string, data string) string

HmacSHA1Base64 HmacSHA1加密

func HmacSHA1Hex

func HmacSHA1Hex(key string, data string) string

HmacSHA1Hex HmacSHA1加密

func IsEmpty

func IsEmpty(arg interface{}) bool

func IsPathExists

func IsPathExists(path string) bool

IsPathExists 判断文件是否存在

func MD5Base64

func MD5Base64(target string) string

MD5Base64 MD5加密

func MD5Hex

func MD5Hex(target string) string

MD5Hex MD5加密

func MachineId

func MachineId() string

MachineId 获取设备ID

func PKCS5Padding

func PKCS5Padding(ciphertext []byte, blockSize int) []byte

PKCS5Padding pkcs5填充

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) []byte

PKCS5UnPadding 删除pkcs5填充的尾部数据

func RedisGet added in v0.2.6

func RedisGet[T any](redisClient *redis.Client, key string, beanPtr *T) error

RedisGet Redis获取(JSON序列化)

func RedisHashGet added in v0.2.6

func RedisHashGet[T any](redisClient *redis.Client, key string, field string, beanPtr *T) error

RedisHashGet Redis获取(JSON序列化)

func RedisHashPut added in v0.2.6

func RedisHashPut(redisClient *redis.Client, key string, field string, data interface{}) error

RedisHashPut Redis保存(JSON序列化)

func RedisPut added in v0.2.6

func RedisPut(redisClient *redis.Client, key string, expire time.Duration, data interface{}) error

RedisPut Redis保存(JSON序列化)

func RsaDecode

func RsaDecode(str []byte, privateKey string) (string, error)

RsaDecode RSA私钥解密

func RsaDecodeWithPublicKey

func RsaDecodeWithPublicKey(str []byte, publicKey string) (string, error)

RsaDecodeWithPublicKey RSA公钥解密

func SM2DecryptHex

func SM2DecryptHex(text string, privateKey string) (string, error)

func SM2EncryptHex

func SM2EncryptHex(text string, publicKey string) (string, error)

func SM3Base64

func SM3Base64(target string) string

SM3Base64 类MD5加密

func SM3Hex

func SM3Hex(target string) string

SM3Hex 类MD5加密

func SM4Decrypt

func SM4Decrypt(data string, SM4Key string, SM4iv string) (res string, err error)

SM4Decrypt SM4解密 传入string 输出string

func SM4Encrypt

func SM4Encrypt(data string, SM4Key string, SM4iv string) (result string, err error)

SM4Encrypt SM4加密:对称加密算法

func StructCopy

func StructCopy(source interface{}, target interface{}, fields ...string) (err error)

StructCopy 结构体复制 source 当前有值的结构体 target 接受值的结构体 fields 需要的设置的属性

func TypeChange

func TypeChange(source string, splitStr string) []int

Types

type IdWorker added in v0.2.1

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

func GetIdWorker added in v0.2.1

func GetIdWorker() *IdWorker

GetIdWorker 获取IdWorker单例

func (*IdWorker) NextId added in v0.2.1

func (idWorker *IdWorker) NextId() int64

NextId 雪花ID

func (*IdWorker) NextIdStr added in v0.2.1

func (idWorker *IdWorker) NextIdStr() string

NextIdStr 雪花ID(String)

func (*IdWorker) RedisId added in v0.2.5

func (idWorker *IdWorker) RedisId(redisClient *redis.Client) int64

RedisId Redis生成ID

func (*IdWorker) UUID added in v0.2.2

func (idWorker *IdWorker) UUID() string

UUID UUID

type Lic

type Lic struct {
	Mac                string `json:"mac"`
	Start              int64  `json:"start"`
	End                int64  `json:"end"`
	CustomerId         string `json:"customerId"`
	CustomerName       string `json:"customerName"`
	CustomerSimpleName string `json:"customerSimpleName"`
	ProductId          string `json:"ProductId"`
	ProductName        string `json:"ProductName"`
}

Lic 授权实体

func CheckLicense

func CheckLicense(licFileName string, productId string, productVersion string) (Lic, error)

CheckLicense 检查授权

type PageInfo

type PageInfo struct {
	PageNum  int64 `json:"pageNum"`
	PageSize int64 `json:"pageSize"`
	Total    int64 `json:"total"`
}

PageInfo 统一报文-翻页信息

type Ret

type Ret struct {
	Code     int      `json:"code"`
	Message  string   `json:"message"`
	Data     any      `json:"data"`
	PageInfo PageInfo `json:"pageInfo"`
}

Ret 统一报文

func Error

func Error(msg string) *Ret

func ErrorWithCode

func ErrorWithCode(code int, msg string) *Ret

func Success

func Success() *Ret

func SuccessWithData

func SuccessWithData(data any) *Ret

func (*Ret) AddData

func (ret *Ret) AddData(key string, data any) *Ret

func (*Ret) SetPageInfo

func (ret *Ret) SetPageInfo(pageNum int64, pageSize int64, total int64) *Ret

SetPageInfo 设置报文翻页信息

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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