crypt

package
v0.0.0-...-5cfbdc7 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: Unlicense Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ValidateSignatureError int = -40001
	ParseXmlError          int = -40002
	ComputeSignatureError  int = -40003
	IllegalAesKey          int = -40004
	ValidateReceiveIdError int = -40005
	EncryptAESError        int = -40006
	DecryptAESError        int = -40007
	IllegalBuffer          int = -40008
	EncodeBase64Error      int = -40009
	DecodeBase64Error      int = -40010
	GenXmlError            int = -40011
	ParseJsonError         int = -40012
	GenJsonError           int = -40013
	IllegalProtocolType    int = -40014
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseContent

type BaseContent struct {
	ReceiveId string `json:"receiveId"` // 公司ID
	MsgType   string `json:"msgType"`   // add_customer|edit_customer|add_user|edit_user
}

BaseContent 消息基础字段

type BizMsg4Recv

type BizMsg4Recv struct {
	MsgType string `json:"msgType"` // add_customer|edit_customer|add_user|edit_user
	Encrypt string `json:"encrypt"`
}

BizMsg4Recv 接收消息结构体

type BizMsg4Send

type BizMsg4Send struct {
	Encrypt   string `json:"encrypt"`
	Signature string `json:"msgSignature"`
	Timestamp string `json:"timeStamp"`
	Nonce     string `json:"nonce"`
}

BizMsg4Send 发送消息结构体

func NewBizMsg4Send

func NewBizMsg4Send(encrypt, signature, timestamp, nonce string) *BizMsg4Send

NewBizMsg4Send 消息发送对象

type BizMsgCrypt

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

func NewBizMsgCrypt

func NewBizMsgCrypt(token, encodingAesKey, receiveId string, protocolType ProtocolType) *BizMsgCrypt

NewBizMsgCrypt 新建加解密对象

func (*BizMsgCrypt) DecryptMsg

func (c *BizMsgCrypt) DecryptMsg(msgSignature, timestamp, nonce string, postData []byte) ([]byte, *Error)

DecryptMsg 消息解密

func (*BizMsgCrypt) EncryptMsg

func (c *BizMsgCrypt) EncryptMsg(replyMsg string) (*BizMsg4Send, *Error)

EncryptMsg 消息加密

func (*BizMsgCrypt) ParsePlainText

func (c *BizMsgCrypt) ParsePlainText(plainText []byte) ([]byte, uint32, []byte, []byte, *Error)

func (*BizMsgCrypt) VerifyURL

func (c *BizMsgCrypt) VerifyURL(msgSignature, timestamp, nonce, echoStr string) ([]byte, *Error)

VerifyURL 验证回调URL

type Error

type Error struct {
	ErrCode int
	ErrMsg  string
}

func NewCryptError

func NewCryptError(errCode int, errMsg string) *Error

NewCryptError 错误信息结构体

type Msg

type Msg struct {
	BaseContent
	Content    string `json:"content"`    // 具体数据字段 (json字符串)
	CreateTime uint32 `json:"createTime"` // 消息创建时间(整型)单位为秒
}

Msg 消息字段

type Processor

type Processor struct {
}

type ProtocolProcessor

type ProtocolProcessor interface {
	// contains filtered or unexported methods
}

ProtocolProcessor 消息处理器

type ProtocolType

type ProtocolType int
const (
	XmlType  ProtocolType = 1
	JsonType ProtocolType = 2
)

Jump to

Keyboard shortcuts

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