Documentation ¶
Index ¶
- Constants
- func AESDecryptMsg(ciphertext []byte, aesKey []byte) (random, rawXMLMsg, appID []byte, err error)
- func AESEncryptMsg(random, rawXMLMsg []byte, appID string, aesKey []byte) (ciphertext []byte)
- func AesECBDecrypt(ciphertext []byte, aesKey []byte) ([]byte, error)
- func CalculateSign(content, signType, key string) (string, error)
- func DecodeWithCommonError(response []byte, apiName string) (err error)
- func DecodeWithError(response []byte, obj interface{}, apiName string) error
- func DecryptMsg(appID, encryptedMsg, aesKey string) (random, rawMsgXMLBytes []byte, err error)
- func EncryptMsg(random, rawXMLMsg []byte, appID, aesKey string) (encrtptMsg []byte, err error)
- func GetCurrTS() int64
- func HTTPGet(uri string) ([]byte, error)
- func HTTPGetContext(ctx context.Context, uri string) ([]byte, error)
- func HTTPPost(uri string, data string) ([]byte, error)
- func HTTPPostContext(ctx context.Context, uri string, data []byte, header map[string]string) ([]byte, error)
- func NewECBDecryptor(b cipher.Block) cipher.BlockMode
- func NewECBEncryptor(b cipher.Block) cipher.BlockMode
- func OrderParam(p map[string]string, bizKey string) (returnStr string)
- func PKCS5Padding(ciphertext []byte, blockSize int) []byte
- func PKCS5UnPadding(origData []byte) []byte
- func ParamSign(p map[string]string, key string) (string, error)
- func PostFile(fieldName, filename, uri string) ([]byte, error)
- func PostJSON(uri string, obj interface{}) ([]byte, error)
- func PostJSONContext(ctx context.Context, uri string, obj interface{}) ([]byte, error)
- func PostJSONWithRespContentType(uri string, obj interface{}) ([]byte, string, error)
- func PostMultipartForm(fields []MultipartFormField, uri string) (respBody []byte, err error)
- func PostXML(uri string, obj interface{}) ([]byte, error)
- func PostXMLWithTLS(uri string, obj interface{}, ca, key string) ([]byte, error)
- func Query(params map[string]interface{}) string
- func RSADecrypt(privateKey string, ciphertext []byte) ([]byte, error)
- func RSADecryptBase64(privateKey string, cryptoText string) ([]byte, error)
- func RandomStr(length int) string
- func Signature(params ...string) string
- func SliceChunk(src []string, chunkSize int) (chunks [][]string)
- func Template(source string, data map[string]interface{}) string
- type CommonError
- type ECBDecryptor
- type ECBEncryptor
- type MultipartFormField
Constants ¶
const ( SignTypeMD5 = `MD5` SignTypeHMACSHA256 = `HMAC-SHA256` )
微信签名算法方式
Variables ¶
This section is empty.
Functions ¶
func AESDecryptMsg ¶
AESDecryptMsg ciphertext = AES_Encrypt[random(16B) + msg_len(4B) + rawXMLMsg + appId] 参考:github.com/chanxuehong/wechat.v2
func AESEncryptMsg ¶
AESEncryptMsg ciphertext = AES_Encrypt[random(16B) + msg_len(4B) + rawXMLMsg + appId] 参考:github.com/chanxuehong/wechat.v2
func AesECBDecrypt ¶ added in v2.0.5
AesECBDecrypt will decrypt data with PKCS5Padding
func CalculateSign ¶ added in v2.0.1
CalculateSign 计算签名
func DecodeWithCommonError ¶
DecodeWithCommonError 将返回值按照CommonError解析
func DecodeWithError ¶
DecodeWithError 将返回值按照解析
func DecryptMsg ¶
DecryptMsg 消息解密
func EncryptMsg ¶
EncryptMsg 加密消息
func HTTPGetContext ¶ added in v2.1.0
HTTPGetContext get 请求
func HTTPPostContext ¶ added in v2.1.0
func HTTPPostContext(ctx context.Context, uri string, data []byte, header map[string]string) ([]byte, error)
HTTPPostContext post 请求
func NewECBDecryptor ¶ added in v2.0.5
NewECBDecryptor returns a BlockMode which decrypts in electronic code book mode, using the given Block.
func NewECBEncryptor ¶ added in v2.0.5
NewECBEncryptor returns a BlockMode which encrypts in electronic code book mode, using the given Block.
func OrderParam ¶
OrderParam order params
func PKCS5Padding ¶ added in v2.0.5
PKCS5Padding -
func PostJSONContext ¶ added in v2.1.5
PostJSONContext post json 数据请求
func PostJSONWithRespContentType ¶
PostJSONWithRespContentType post json数据请求,且返回数据类型
func PostMultipartForm ¶
func PostMultipartForm(fields []MultipartFormField, uri string) (respBody []byte, err error)
PostMultipartForm 上传文件或其他多个字段
func PostXMLWithTLS ¶
PostXMLWithTLS perform a HTTP/POST request with XML body and TLS
func RSADecrypt ¶ added in v2.0.7
RSADecrypt 数据解密
func RSADecryptBase64 ¶ added in v2.0.7
RSADecryptBase64 Base64解码后再次进行RSA解密
func SliceChunk ¶ added in v2.0.5
SliceChunk 用于将字符串切片分块
Types ¶
type CommonError ¶
type CommonError struct { ErrCode int64 `json:"errcode"` ErrMsg string `json:"errmsg"` // contains filtered or unexported fields }
CommonError 微信返回的通用错误json
func NewCommonError ¶ added in v2.1.4
func NewCommonError(apiName string, code int64, msg string) *CommonError
NewCommonError 新建CommonError错误,对于无errcode和errmsg的返回也可以返回该通用错误
func (*CommonError) Error ¶ added in v2.1.4
func (c *CommonError) Error() string
type ECBDecryptor ¶ added in v2.0.5
type ECBDecryptor ecb
ECBDecryptor -
func (*ECBDecryptor) BlockSize ¶ added in v2.0.5
func (x *ECBDecryptor) BlockSize() int
BlockSize implement BlockMode.BlockSize
func (*ECBDecryptor) CryptBlocks ¶ added in v2.0.5
func (x *ECBDecryptor) CryptBlocks(dst, src []byte)
CryptBlocks implement BlockMode.CryptBlocks
type ECBEncryptor ¶ added in v2.0.5
type ECBEncryptor ecb
ECBEncryptor -
func (*ECBEncryptor) BlockSize ¶ added in v2.0.5
func (x *ECBEncryptor) BlockSize() int
BlockSize implement BlockMode.BlockSize
func (*ECBEncryptor) CryptBlocks ¶ added in v2.0.5
func (x *ECBEncryptor) CryptBlocks(dst, src []byte)
CryptBlocks implement BlockMode.CryptBlocks