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 HTTPPost(uri string, data 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 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 RandomStr(length int) string
- func Signature(params ...string) string
- func SliceChunk(src []string, chunkSize int) (chunks [][]string)
- type CommonError
- type CryptError
- type ECBDecryptor
- type ECBEncryptor
- type JsonProcessor
- type MultipartFormField
- type ProtocolProcessor
- type ProtocolType
- type WXBizJsonMsg4Recv
- type WXBizJsonMsg4Send
- type WXBizMsgCrypt
- func (self *WXBizMsgCrypt) DecryptMsg(msg_signature, timestamp, nonce string, post_data []byte) ([]byte, *CryptError)
- func (self *WXBizMsgCrypt) EncryptMsg(reply_msg, timestamp, nonce string) ([]byte, *CryptError)
- func (self *WXBizMsgCrypt) ParsePlainText(plaintext []byte) ([]byte, uint32, []byte, []byte, *CryptError)
- func (self *WXBizMsgCrypt) VerifyURL(msg_signature, timestamp, nonce, echostr string) ([]byte, *CryptError)
Constants ¶
const ( SignTypeMD5 = `MD5` SignTypeHMACSHA256 = `HMAC-SHA256` )
微信签名算法方式
const ( ValidateSignatureError int = -40001 ParseJsonError int = -40002 ComputeSignatureError int = -40003 IllegalAesKey int = -40004 ValidateCorpidError int = -40005 EncryptAESError int = -40006 DecryptAESError int = -40007 IllegalBuffer int = -40008 EncodeBase64Error int = -40009 DecodeBase64Error int = -40010 GenJsonError int = -40011 IllegalProtocolType int = -40012 )
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 ¶
AesECBDecrypt will decrypt data with PKCS5Padding
func CalculateSign ¶
CalculateSign 计算签名
func DecodeWithCommonError ¶
DecodeWithCommonError 将返回值按照CommonError解析
func DecodeWithError ¶
DecodeWithError 将返回值按照解析
func DecryptMsg ¶
DecryptMsg 消息解密
func EncryptMsg ¶
EncryptMsg 加密消息
func NewECBDecryptor ¶
NewECBDecryptor returns a BlockMode which decrypts in electronic code book mode, using the given Block.
func NewECBEncryptor ¶
NewECBEncryptor returns a BlockMode which encrypts in electronic code book mode, using the given Block.
func OrderParam ¶
OrderParam order params
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 SliceChunk ¶
SliceChunk 用于将字符串切片分块
Types ¶
type CommonError ¶
CommonError 微信返回的通用错误json
type CryptError ¶
func NewCryptError ¶
func NewCryptError(err_code int, err_msg string) *CryptError
type ECBDecryptor ¶
type ECBDecryptor ecb
ECBDecryptor -
func (*ECBDecryptor) BlockSize ¶
func (x *ECBDecryptor) BlockSize() int
BlockSize implement BlockMode.BlockSize
func (*ECBDecryptor) CryptBlocks ¶
func (x *ECBDecryptor) CryptBlocks(dst, src []byte)
CryptBlocks implement BlockMode.CryptBlocks
type ECBEncryptor ¶
type ECBEncryptor ecb
ECBEncryptor -
func (*ECBEncryptor) BlockSize ¶
func (x *ECBEncryptor) BlockSize() int
BlockSize implement BlockMode.BlockSize
func (*ECBEncryptor) CryptBlocks ¶
func (x *ECBEncryptor) CryptBlocks(dst, src []byte)
CryptBlocks implement BlockMode.CryptBlocks
type JsonProcessor ¶
type JsonProcessor struct { }
type MultipartFormField ¶
MultipartFormField 保存文件或其他字段信息
type ProtocolProcessor ¶
type ProtocolProcessor interface {
// contains filtered or unexported methods
}
type WXBizJsonMsg4Recv ¶
type WXBizJsonMsg4Send ¶
type WXBizJsonMsg4Send struct { Encrypt string `json:"encrypt"` Signature string `json:"msgsignature"` Timestamp string `json:"timestamp"` Nonce string `json:"nonce"` }
func NewWXBizJsonMsg4Send ¶
func NewWXBizJsonMsg4Send(encrypt, signature, timestamp, nonce string) *WXBizJsonMsg4Send
type WXBizMsgCrypt ¶
type WXBizMsgCrypt struct {
// contains filtered or unexported fields
}
func NewWXBizMsgCrypt ¶
func NewWXBizMsgCrypt(token, encoding_aeskey, receiver_id string, protocol_type ProtocolType) *WXBizMsgCrypt
func (*WXBizMsgCrypt) DecryptMsg ¶
func (self *WXBizMsgCrypt) DecryptMsg(msg_signature, timestamp, nonce string, post_data []byte) ([]byte, *CryptError)
func (*WXBizMsgCrypt) EncryptMsg ¶
func (self *WXBizMsgCrypt) EncryptMsg(reply_msg, timestamp, nonce string) ([]byte, *CryptError)
func (*WXBizMsgCrypt) ParsePlainText ¶
func (self *WXBizMsgCrypt) ParsePlainText(plaintext []byte) ([]byte, uint32, []byte, []byte, *CryptError)
func (*WXBizMsgCrypt) VerifyURL ¶
func (self *WXBizMsgCrypt) VerifyURL(msg_signature, timestamp, nonce, echostr string) ([]byte, *CryptError)