lib

package
v0.0.0-...-c04114d Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2018 License: MIT Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckSignature

func CheckSignature(t string, w http.ResponseWriter, r *http.Request) bool

func CheckSignatureInQuery

func CheckSignatureInQuery(t string, w http.ResponseWriter, r *http.Request) bool

func MsgSign

func MsgSign(token, timestamp, nonce, encryptedMsg string) (signature string)

微信公众号/企业号 密文模式消息签名

func Sign

func Sign(token, timestamp, nonce string) (signature string)

微信公众号 明文模式/URL认证 签名

Types

type Cipher

type Cipher struct {
	MessageCrypter
	// contains filtered or unexported fields
}

用于管道加密

func (*Cipher) CheckSign

func (c *Cipher) CheckSign(w http.ResponseWriter, r *http.Request) bool

func (*Cipher) CheckSignQuery

func (c *Cipher) CheckSignQuery(w http.ResponseWriter, r *http.Request) bool

func (*Cipher) Decrypt

func (c *Cipher) Decrypt(r io.Reader) (b []byte, err error)

从r读取并解密

func (*Cipher) Encrypt

func (c *Cipher) Encrypt(w io.Writer, b []byte) (err error)

将b加密写入w

type IOCipher

type IOCipher interface {
	Encrypt(w io.Writer, b []byte) (err error)
	Decrypt(r io.Reader) (b []byte, err error)
	CheckSign(w http.ResponseWriter, r *http.Request) bool
	CheckSignQuery(w http.ResponseWriter, r *http.Request) bool
}

包装读写接口 使其能读写加解密

func NewCipher

func NewCipher(token, encodingAESKey, appID string) (IOCipher, error)

type MessageCrypter

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

用于微信消息的加解密 messageCrypter 封装了生成签名和消息加解密的方法

func NewmessageCrypter

func NewmessageCrypter(token, encodingAESKey, appID string) (MessageCrypter, error)

NewmessageCrypter 方法用于创建 messageCrypter 实例

token 为开发者在微信开放平台上设置的 Token, encodingAESKey 为开发者在微信开放平台上设置的 EncodingAESKey, appID 为企业号的 CorpId 或者 AppId

func (MessageCrypter) Decrypt

func (w MessageCrypter) Decrypt(text string) ([]byte, string, error)

Decrypt 方法用于对密文进行解密

返回解密后的消息,CropId/AppId, 或者错误信息

Jump to

Keyboard shortcuts

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