Documentation ¶
Overview ¶
Package helper (helper)
Index ¶
- type UtilHelper
- func (h *UtilHelper) AESDecrypt(_ context.Context, key, data []byte) (dst string, err error)
- func (h *UtilHelper) AESEncrypt(_ context.Context, key, data []byte) (dst string, err error)
- func (h *UtilHelper) AuthToken(ctx context.Context, accountNo uint64) string
- func (h *UtilHelper) Base58Encode(data []byte) string
- func (h *UtilHelper) CheckFileExists(ctx context.Context, filePath string) (err error)
- func (h *UtilHelper) CompareHashAndPassword(inputPass, authPass string) bool
- func (h *UtilHelper) ConcatenateSignSource(ctx context.Context, data interface{}) string
- func (h *UtilHelper) CreateAccessToken(ctx context.Context, accountNo uint64) (token string, err error)
- func (h *UtilHelper) DecryptSignDataInfo(src []byte, key []byte) (dst []byte, err error)
- func (h *UtilHelper) EncryptPass(pass string) ([]byte, error)
- func (h *UtilHelper) EncryptSignData(_ context.Context, data interface{}, key []byte) ([]byte, error)
- func (h *UtilHelper) GenerateShortLink(_ context.Context, url string) (str string, err error)
- func (h *UtilHelper) GetAESPassword(originPasswd string) (passwd string, salt string, err error)
- func (h *UtilHelper) GetLocalIPV4(ctx context.Context) string
- func (h *UtilHelper) GetOriginPassword(aesPasswd, salt string) (passwd string, err error)
- func (h *UtilHelper) GetOutBoundIP(ctx context.Context) string
- func (h *UtilHelper) Header(_ context.Context) map[string]string
- func (h *UtilHelper) HeaderToMap(header http.Header) map[string]interface{}
- func (h *UtilHelper) HexDecodeString(ctx context.Context, data string, key []byte) ([]byte, error)
- func (h *UtilHelper) InitOrderID(ctx context.Context, datacenterID, workerID int64) int64
- func (h *UtilHelper) InitRandStr(n int) string
- func (h *UtilHelper) InitTrxID(ctx context.Context, ano uint64) uint64
- func (h *UtilHelper) LcFirst(str string) string
- func (h *UtilHelper) Logger(ctx context.Context) string
- func (h *UtilHelper) PasswordBase58Hash(password string) (string, error)
- func (h *UtilHelper) ReplaceCdnStaticAddress(ctx context.Context, url string) string
- func (h *UtilHelper) RequestTime(_ context.Context, ts string) *gtime.Time
- func (h *UtilHelper) Sha256Of(input []byte) string
- func (h *UtilHelper) Sha256OfShort(input string) ([]byte, error)
- func (h *UtilHelper) SnowflakeInstance(ctx context.Context, datacenterID, workerID int64) *snowflake.Snowflake
- func (h *UtilHelper) UcFirst(str string) string
- func (h *UtilHelper) UserAgent(_ context.Context) string
- func (h *UtilHelper) UserAgentIPHash(useragent string, ip string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type UtilHelper ¶
type UtilHelper struct { }
UtilHelper .
func (*UtilHelper) AESDecrypt ¶
AESDecrypt decrypts the input byte array with the given key
func (*UtilHelper) AESEncrypt ¶
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 (*UtilHelper) GenerateShortLink ¶
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 ¶
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) 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 ¶
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) 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