crypter

package module
v0.0.0-...-4aaa463 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2015 License: MIT Imports: 12 Imported by: 4

README

wechat-crypter

微信开放平台加解密库 (Golang)

Usage

$ go get github.com/KonishiLee/wechat-crypter
import "github.com/KonishiLee/wechat-crypter"

token := "RMNlACHlV5ThzfRlVS4D4"
corpID := "wx5823bf96d3bd56c7"
encodingAESKey := "jWmYm7qr5nMoAUwZRjGtBxmz3KA1tkAj3ykkR6q2B2C"

msgCrypter, _ := crypter.NewMessageCrypter(token, encodingAESKey, corpID)
msgDecrypt, corpID, err := msgCrypter.Decrypt("msgEncrypt")

Doc

http://godoc.org/github.com/KonishiLee/wechat-crypter

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PKCS7Decode

func PKCS7Decode(text []byte) []byte

PKCS7Decode 方法用于删除解密后明文的补位字符

func PKCS7Encode

func PKCS7Encode(text []byte) []byte

PKCS7Encode 方法用于对需要加密的明文进行填充补位

Types

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, 或者错误信息

func (MessageCrypter) Encrypt

func (w MessageCrypter) Encrypt(text string) (string, error)

Encrypt 方法用于对明文进行加密

func (MessageCrypter) GetSignature

func (w MessageCrypter) GetSignature(timestamp, nonce, msgEncrypt string) string

GetSignature 方法用于返回签名

Jump to

Keyboard shortcuts

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