util

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2020 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidBlockSize    = errors.New("invalid block size")
	ErrInvalidPKCS7Data    = errors.New("invalid PKCS7 data")
	ErrInvalidPKCS7Padding = errors.New("invalid padding on input")
)

Functions

func AesDecryptECB added in v0.5.0

func AesDecryptECB(encrypted []byte, key []byte) (decrypted []byte)

AES-256-ECB解密 encrypted解压数据

func BuildByMap added in v0.5.0

func BuildByMap(data map[string]interface{}) string

map构建xml字符串

func CheckSignature added in v0.6.1

func CheckSignature(token, timestamp, nonce, signature string) bool

func Decrypt

func Decrypt(v interface{}, sessionKey, encryptedData, ivStr string) error

cbc解密用户信息 sessionKey 微信 session_key rawData 不包括敏感信息的原始数据字符串,用于计算签名。 encryptedData 包括敏感数据在内的完整用户信息的加密数据 ivStr 加密算法的初始向量

func DecryptInfo added in v0.2.0

func DecryptInfo(v interface{}, sessionKey, rawData, encryptedData, signature, iv string) error

DecryptInfo 解密用户信息

sessionKey 微信 session_key rawData 不包括敏感信息的原始数据字符串,用于计算签名。 encryptedData 包括敏感数据在内的完整用户信息的加密数据 signature 使用 sha1( rawData + session_key ) 得到字符串,用于校验用户信息 iv 加密算法的初始向量

func Gen

func Gen(arr []string) (string, error)

组装url参数并签名

func GenWithAmple

func GenWithAmple(arr []string) (string, error)

组装url参数并签名

func HmacSha256 added in v0.2.0

func HmacSha256(str, key string) string

HmacSha256 签名

func IsAnyEmpty

func IsAnyEmpty(values ...string) bool

是否为空

func Md5 added in v0.2.0

func Md5(str string) string

Md5 签名

func NewTLSClient added in v0.2.0

func NewTLSClient(certPath, keyPath string) (*http.Client, error)

NewTLSClient 创建支持双向证书认证的 http.Client.

func NewTLSClientByPkc12 added in v0.5.0

func NewTLSClientByPkc12(data []byte, pw string) (*http.Client, error)

NewTLSClientByPkc12 通过pkc12证书创建支持双向证书认证的 http.Client.

func Pkcs7Unpacked added in v0.2.0

func Pkcs7Unpacked(data []byte, blockSize int) ([]byte, error)

解压 pkcs7Unpacked returns slice of the original data without padding

func RandSeq

func RandSeq(n int) string

获取长度n的随机字符串

func RsaEncrypt added in v0.5.0

func RsaEncrypt(data []byte, publicKey []byte) ([]byte, error)

Rsa加密

func ToMap added in v0.5.0

func ToMap(request interface{}) map[string]interface{}

结构体转map[string]interface{}

func TrimToUpper added in v0.5.0

func TrimToUpper(str string) string

转大写

Types

This section is empty.

Jump to

Keyboard shortcuts

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