helper

package
v0.0.0-...-c1bb697 Latest Latest
Warning

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

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

Documentation

Overview

Package helper (helper)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type UtilHelper

type UtilHelper struct {
}

UtilHelper .

func Helper

func Helper() *UtilHelper

Helper .

func (*UtilHelper) AESDecrypt

func (h *UtilHelper) AESDecrypt(_ context.Context, key, data []byte) (dst string, err error)

AESDecrypt decrypts the input byte array with the given key

func (*UtilHelper) AESEncrypt

func (h *UtilHelper) AESEncrypt(_ context.Context, key, data []byte) (dst string, err error)

AESEncrypt encrypts the input byte array with the given key

func (*UtilHelper) AuthToken

func (h *UtilHelper) AuthToken(ctx context.Context, accountNo uint64) string

AuthToken user auth token

func (*UtilHelper) Base58Encode

func (h *UtilHelper) Base58Encode(data []byte) string

Base58Encode encodes the input byte array to base58 string

func (*UtilHelper) CheckFileExists

func (h *UtilHelper) CheckFileExists(ctx context.Context, filePath string) (err error)

CheckFileExists .

func (*UtilHelper) CompareHashAndPassword

func (h *UtilHelper) CompareHashAndPassword(inputPass, authPass string) bool

CompareHashAndPassword 校验密码。

func (*UtilHelper) ConcatenateSignSource

func (h *UtilHelper) ConcatenateSignSource(ctx context.Context, data interface{}) string

ConcatenateSignSource get sign URL 排序并拼接签名的内容信息

func (*UtilHelper) CreateAccessToken

func (h *UtilHelper) CreateAccessToken(ctx context.Context, accountNo uint64) (token string, err error)

CreateAccessToken create access token

func (*UtilHelper) DecryptSignDataInfo

func (h *UtilHelper) DecryptSignDataInfo(src []byte, key []byte) (dst []byte, err error)

DecryptSignDataInfo sign data 数据执行 aes 解密

func (*UtilHelper) EncryptPass

func (h *UtilHelper) EncryptPass(pass string) ([]byte, error)

EncryptPass .加密处理

func (*UtilHelper) EncryptSignData

func (h *UtilHelper) EncryptSignData(_ context.Context, data interface{}, key []byte) ([]byte, error)

EncryptSignData sign data

func (h *UtilHelper) GenerateShortLink(_ context.Context, url string) (str string, err error)

GenerateShortLink generate short link

func (*UtilHelper) GetAESPassword

func (h *UtilHelper) GetAESPassword(originPasswd string) (passwd string, salt string, err error)

GetAESPassword .

func (*UtilHelper) GetLocalIPV4

func (h *UtilHelper) GetLocalIPV4(ctx context.Context) string

GetLocalIPV4 获取 IPV4 IP,没有则返回空

func (*UtilHelper) GetOriginPassword

func (h *UtilHelper) GetOriginPassword(aesPasswd, salt string) (passwd string, err error)

GetOriginPassword .

func (*UtilHelper) GetOutBoundIP

func (h *UtilHelper) GetOutBoundIP(ctx context.Context) string

GetOutBoundIP 获取本机 IP

func (*UtilHelper) Header

func (h *UtilHelper) Header(_ context.Context) map[string]string

Header .

func (*UtilHelper) HeaderToMap

func (h *UtilHelper) HeaderToMap(header http.Header) map[string]interface{}

HeaderToMap covert request headers to map.

func (*UtilHelper) HexDecodeString

func (h *UtilHelper) HexDecodeString(ctx context.Context, data string, key []byte) ([]byte, error)

HexDecodeString .

func (*UtilHelper) InitOrderID

func (h *UtilHelper) InitOrderID(ctx context.Context, datacenterID, workerID int64) int64

InitOrderID init64 order id

func (*UtilHelper) InitRandStr

func (h *UtilHelper) InitRandStr(n int) string

InitRandStr RandStringBytesMaskImprSrcUnsafe

func (*UtilHelper) InitTrxID

func (h *UtilHelper) InitTrxID(ctx context.Context, ano uint64) uint64

InitTrxID .根据上下文以及账户标识获取交易订单号

func (*UtilHelper) LcFirst

func (h *UtilHelper) LcFirst(str string) string

LcFirst 首字母小写

func (*UtilHelper) Logger

func (h *UtilHelper) Logger(ctx context.Context) string

Logger .获取上下文中的 logger

func (*UtilHelper) PasswordBase58Hash

func (h *UtilHelper) PasswordBase58Hash(password string) (string, error)

PasswordBase58Hash password base58 hash

func (*UtilHelper) ReplaceCdnStaticAddress

func (h *UtilHelper) ReplaceCdnStaticAddress(ctx context.Context, url string) string

ReplaceCdnStaticAddress .

func (*UtilHelper) RequestTime

func (h *UtilHelper) RequestTime(_ context.Context, ts string) *gtime.Time

RequestTime .request time

func (*UtilHelper) Sha256Of

func (h *UtilHelper) Sha256Of(input []byte) string

Sha256Of returns the sha256 of the input string

func (*UtilHelper) Sha256OfShort

func (h *UtilHelper) Sha256OfShort(input string) ([]byte, error)

Sha256OfShort returns the sha256 of the input string

func (*UtilHelper) SnowflakeInstance

func (h *UtilHelper) SnowflakeInstance(ctx context.Context, datacenterID, workerID int64) *snowflake.Snowflake

SnowflakeInstance Get Client Instance datacenterID Datacenter ID must be greater than or equal to 0 workerID Worker ID must be greater than or equal to 0

func (*UtilHelper) UcFirst

func (h *UtilHelper) UcFirst(str string) string

UcFirst 首字母大些

func (*UtilHelper) UserAgent

func (h *UtilHelper) UserAgent(_ context.Context) string

UserAgent is a default HTTP userAgent

func (*UtilHelper) UserAgentIPHash

func (h *UtilHelper) UserAgentIPHash(useragent string, ip string) string

UserAgentIPHash user agent ip hash

Jump to

Keyboard shortcuts

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