helper

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package helper universal tool package

Index

Constants

View Source
const (
	// OtherSettleParams 其他分账方参数 (Other settle params)
	OtherSettleParams = "other_settle_params"
	// AppID 小程序 appID (Applets appID)
	AppID = "app_id"
	// ThirdPartyID 代小程序进行该笔交易调用的第三方平台服务商 id (The id of the third-party platform service provider that calls the transaction on behalf of the Applets)
	ThirdPartyID = "thirdparty_id"
	// Sign 签名 (sign)
	Sign = "sign"
	// Timestamp 时间戳 (timestamp)
	Timestamp = "timestamp"
	// Nonce 随机字符串 (nonce)
	Nonce = "nonce"
	// Msg 消息体 (msg)
	Msg = "msg"
)

Variables

This section is empty.

Functions

func CallbackSign added in v0.0.6

func CallbackSign(_ context.Context, token string, data any) string

CallbackSign 担保支付回调签名算法 参数:"strArr" 所有字段(验证时注意不包含 sign 签名本身,不包含空字段与 type 常量字段)内容与平台上配置的 token 返回:签名字符串

CallbackSign Guaranteed payment callback signature algorithm Param: "strArr" The content of all fields (note that the sign signature itself is not included during verification, and does not include empty fields and type constant fields) content and the token configured on the platform Return: signature string

func CheckSign

func CheckSign(timestamp, nonce, body, signature, pubKeyStr string) (bool, error)

CheckSign 校验签名

func GenSign

func GenSign(method, url, timestamp, nonce, body string, key []byte, keyType config.Secret) (sign string, err error)

GenSign 生成签名

func GetCurrTS added in v0.0.3

func GetCurrTS() int64

GetCurrTS return current timestamps

func LcFirst added in v0.0.6

func LcFirst(str string) string

LcFirst 首字母小写

func OrderParam added in v0.0.3

func OrderParam(p map[string]string, bizKey string) (returnStr string)

OrderParam order params

func ParsePrivateKey added in v0.1.0

func ParsePrivateKey(privateKeyDecoded []byte, keyType config.Secret) (*rsa.PrivateKey, error)

ParsePrivateKey parses private key bytes to rsa privateKey

func PemToRSAPublicKey

func PemToRSAPublicKey(pemKeyStr string) (*rsa.PublicKey, error)

PemToRSAPublicKey pem to rsa public key

func Query added in v0.0.3

func Query(params map[string]interface{}) string

Query 将 Map 序列化为 Query 参数

func RSADecrypt added in v0.0.3

func RSADecrypt(privateKey string, ciphertext []byte) ([]byte, error)

RSADecrypt 数据解密

func RSADecryptBase64 added in v0.0.3

func RSADecryptBase64(privateKey string, cryptoText string) ([]byte, error)

RSADecryptBase64 Base64 解码后再次进行 RSA 解密

func RandomStr added in v0.0.3

func RandomStr(n int) string

RandomStr 随机生成字符串

func RequestSign added in v0.0.6

func RequestSign(_ context.Context, data interface{}, salt string) string

RequestSign Guaranteed Payment Request Signature Algorithm Param: "paramsMap" all request parameters Return: signature string

func SliceChunk added in v0.0.3

func SliceChunk(src []string, chunkSize int) (chunks [][]string)

SliceChunk 用于将字符串切片分块

func Template added in v0.0.3

func Template(source string, data map[string]interface{}) string

Template 对字符串中的和 map 的 key 相同的字符串进行模板替换 仅支持 形如:{name}

func UcFirst added in v0.0.6

func UcFirst(str string) string

UcFirst 首字母大些

Types

This section is empty.

Jump to

Keyboard shortcuts

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