util

package
v0.0.0-...-94ae32f Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SignTypeMD5        = `MD5`
	SignTypeHMACSHA256 = `HMAC-SHA256`
)

微信签名算法方式

Variables

This section is empty.

Functions

func AESDecryptMsg

func AESDecryptMsg(ciphertext []byte, aesKey []byte) (random, rawXMLMsg, appID []byte, err error)

AESDecryptMsg ciphertext = AES_Encrypt[random(16B) + msg_len(4B) + rawXMLMsg + appId] 参考:github.com/chanxuehong/wechat.v2

func AESEncryptMsg

func AESEncryptMsg(random, rawXMLMsg []byte, appID string, aesKey []byte) (ciphertext []byte)

AESEncryptMsg ciphertext = AES_Encrypt[random(16B) + msg_len(4B) + rawXMLMsg + appId] 参考:github.com/chanxuehong/wechat.v2

func AesECBDecrypt

func AesECBDecrypt(ciphertext []byte, aesKey []byte) ([]byte, error)

AesECBDecrypt will decrypt data with PKCS5Padding

func CalculateSign

func CalculateSign(content, signType, key string) (string, error)

CalculateSign 计算签名

func DecryptMsg

func DecryptMsg(appID, encryptedMsg, aesKey string) (random, rawMsgXMLBytes []byte, err error)

DecryptMsg 消息解密

func EncryptMsg

func EncryptMsg(random, rawXMLMsg []byte, appID, aesKey string) (encrtptMsg []byte, err error)

EncryptMsg 加密消息

func HTTPGet

func HTTPGet(uri string) ([]byte, error)

HTTPGet 网络拉取请求

func HTTPPost

func HTTPPost(uri string, data string) ([]byte, error)

HTTPPost 网络投递请求

func InMicroMessenger

func InMicroMessenger(userAgent string) bool

InMicroMessenger 判断是否在微信内部打开

func NewECBDecryptor

func NewECBDecryptor(b cipher.Block) cipher.BlockMode

NewECBDecryptor returns a BlockMode which decrypts in electronic code book mode, using the given Block.

func NewECBEncryptor

func NewECBEncryptor(b cipher.Block) cipher.BlockMode

NewECBEncryptor returns a BlockMode which encrypts in electronic code book mode, using the given Block.

func OrderParam

func OrderParam(p map[string]string, bizKey string) (returnStr string)

OrderParam order params

func PKCS5Padding

func PKCS5Padding(ciphertext []byte, blockSize int) []byte

PKCS5Padding -

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) []byte

PKCS5UnPadding -

func ParamSign

func ParamSign(p map[string]string, key string) (string, error)

ParamSign 计算所传参数的签名

func PostJSON

func PostJSON(url string, object interface{}) ([]byte, error)

PostJSON 发送 JSON 数据请求。

func Signature

func Signature(x ...string) string

Signature sha1 签名。

func TryDecodeError

func TryDecodeError(data []byte, apiName string) (err error)

TryDecodeError 尝试解码响应错误。

Types

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 WechatError

type WechatError struct {
	ErrCode int64  `json:"errcode"`
	ErrMsg  string `json:"errmsg,omitempty"`
}

WechatError 是微信接口通用错误结构体。

func UnknownError

func UnknownError(err error) *WechatError

UnknownError 返回一个未知错误信息。

func (*WechatError) Success

func (e *WechatError) Success() bool

Jump to

Keyboard shortcuts

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