wechat

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2021 License: MIT Imports: 11 Imported by: 0

README

Wechat AES

Build Status codecov GitHub release (latest by date) MIT Licence GoDoc GitHub code size

提供接收和推送给微信公众平台消息的加解密接口

参见微信开放平台->第三方平台->消息加解密接入指引

Documentation

Index

Constants

View Source
const ComputeSignatureError int = -40003
View Source
const DecryptAESError int = -40007
View Source
const EncryptAESError int = -40006
View Source
const IllegalAesKey int = -40004
View Source
const IllegalBuffer int = -40008
View Source
const OK int = 0
View Source
const ParseXmlError int = -40002
View Source
const ValidateAppidError int = -40005
View Source
const ValidateSignatureError int = -40001
View Source
const WechatCryptorEncryptMsgFormat = `` /* 148-byte string literal not displayed */

Variables

This section is empty.

Functions

func SHA1

func SHA1(token, timestamp, nonce, encrypt string) string

func WechatCryptorRandomStr

func WechatCryptorRandomStr() string

随机生成16位字符串

Types

type WechatCryptor

type WechatCryptor struct {
	// contains filtered or unexported fields
}

func NewWechatCryptor

func NewWechatCryptor(appId, token, encodingAesKey string) (*WechatCryptor, error)

构造函数 appId 公众平台appid token 公众平台上,开发者设置的token aesKey 公众平台上,开发者设置的EncodingAESKey

func (*WechatCryptor) Decrypt

func (cryptor *WechatCryptor) Decrypt(text string) (string, error)

对密文进行解密

func (*WechatCryptor) DecryptMsg

func (cryptor *WechatCryptor) DecryptMsg(msgSign, timeStamp, nonce, postData string) (string, error)

func (*WechatCryptor) DecryptMsgContent

func (cryptor *WechatCryptor) DecryptMsgContent(msgSign, timeStamp, nonce, encrypt string) (string, error)

func (*WechatCryptor) Encrypt

func (cryptor *WechatCryptor) Encrypt(randomStr, text string) (string, error)

对明文进行加密

func (*WechatCryptor) EncryptMsg

func (cryptor *WechatCryptor) EncryptMsg(msg, timeStamp, nonce string) (string, error)

func (*WechatCryptor) EncryptMsgContent

func (cryptor *WechatCryptor) EncryptMsgContent(msg, timeStamp, nonce string) (string, string, string, string, error)

func (*WechatCryptor) String

func (cryptor *WechatCryptor) String() string

type WechatCryptorError

type WechatCryptorError struct {
	Code int
}

* 异常的错误码和具体的错误信息

func (*WechatCryptorError) Error

func (e *WechatCryptorError) Error() string

type WechatCryptorPostBody

type WechatCryptorPostBody struct {
	XMLName    xml.Name `xml:"xml"`
	ToUserName string   `xml:"ToUserName"`
	AppId      string   `xml:"AppId"`
	Encrypt    string   `xml:"Encrypt"`
}

Jump to

Keyboard shortcuts

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