helper

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package helper universal tool package

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckSign

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

CheckSign 校验签名

func GenSign

func GenSign(method, url, timestamp, nonce, body string, privateKey *rsa.PrivateKey) (sign string, err error)

GenSign 生成签名

func GetCurrTS added in v0.0.3

func GetCurrTS() int64

GetCurrTS return current timestamps

func OrderParam added in v0.0.3

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

OrderParam order params

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 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}

Types

This section is empty.

Jump to

Keyboard shortcuts

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