util

package
v1.1.2-0...-e53d5f3 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2018 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AesECBDecrypt

func AesECBDecrypt(ciphertext, key []byte) (plaintext []byte, err error)

AesECBDecrypt CBC解密数据

@ciphertext 加密数据 @key 商户支付密钥

func CBCDecrypt

func CBCDecrypt(ssk, data, iv string) (bts []byte, err error)

CBCDecrypt CBC解密数据

@ssk 通过 Login 向微信服务端请求得到的 session_key @data 小程序通过 api 得到的加密数据(encryptedData) @iv 小程序通过 api 得到的初始向量(iv)

func CBCEncrypt

func CBCEncrypt(key, data string) (ciphertext []byte, err error)

CBCEncrypt CBC加密数据

func FetchIP

func FetchIP() (net.IP, error)

FetchIP current IP address

func GetQuery

func GetQuery(req *http.Request, key string) string

GetQuery returns url query value

func MD5

func MD5(str string) (string, error)

MD5 加密

func NewTLSClient

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

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

func PKCS5Padding

func PKCS5Padding(ciphertext []byte, blockSize int) []byte

PKCS5Padding 补位 Golang AES没有64位的块, 如果采用PKCS5, 那么实质上就是采用PKCS7

func PKCS5UnPadding

func PKCS5UnPadding(plaintext []byte) ([]byte, error)

PKCS5UnPadding 反补 Golang AES没有64位的块, 如果采用PKCS5, 那么实质上就是采用PKCS7

func PostXML

func PostXML(uri string, obj interface{}) ([]byte, error)

PostXML perform a HTTP/POST request with XML body

func RandomString

func RandomString(ln int) string

RandomString random string generator

@ln length of return string

func SignByMD5

func SignByMD5(data map[string]string, key string) (string, error)

SignByMD5 多参数通过MD5签名

func TSLPostXML

func TSLPostXML(uri string, obj interface{}, certPath, keyPath string) ([]byte, error)

TSLPostXML ...

func TokenAPI

func TokenAPI(api, token string) (string, error)

TokenAPI 获取带 token 的 API 地址

func Validate

func Validate(rawData, ssk, signature string) bool

Validate 对数据包进行签名校验,确保数据的完整性。

@rawData 不包括敏感信息的原始数据字符串,用于计算签名。 @signature 使用 sha1( rawData + sessionkey ) 得到字符串,用于校验用户信息 @ssk 微信 session_key

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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