Documentation
¶
Index ¶
- Variables
- func AesCBCDecrypt(sessionKey, encryptedData, iv string) (plaintext []byte, err error)
- func CheckSignature(signature, sessionKey, rawData string) bool
- func CodeToURL(appID, secret, code string) (string, error)
- func PKCS5UnPadding(plaintext []byte, blockSize int) ([]byte, error)
- func Sha1(key string) string
- type Client
- type CommonResponse
- type DebugRequestTransport
- type LoginResponse
- type UserInfo
- type Watermark
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrSignature = errors.New("signature error") ErrPaddingSize = errors.New("padding size error") )
Functions ¶
func AesCBCDecrypt ¶
接口返回的加密数据( encryptedData )进行对称解密。 解密算法如下: 对称解密使用的算法为 AES-128-CBC,数据采用PKCS#7填充。 对称解密的目标密文为 Base64_Decode(encryptedData)。 对称解密秘钥 aeskey = Base64_Decode(session_key), aeskey 是16字节。 对称解密算法初始向量 为Base64_Decode(iv),其中iv由数据接口返回。 AES并没有64位的块, 如果采用PKCS5, 那么实质上就是采用PKCS7
func CheckSignature ¶
func PKCS5UnPadding ¶
Types ¶
type CommonResponse ¶
type CommonResponse struct {
Errcode int `json:"errcode,omitempty"`
Errmsg string `json:"errmsg,omitempty"`
}
Response 请求微信返回基础数据
type DebugRequestTransport ¶
type DebugRequestTransport struct {
RequestHeader bool
RequestBody bool // RequestHeader 为 true 时,这个选项才会生效
ResponseHeader bool
ResponseBody bool // ResponseHeader 为 true 时,这个选项才会生效
// debug 信息输出到 Writer 中, 默认是 os.Stderr
Writer io.Writer
Transport http.RoundTripper
}
DebugRequestTransport 会打印请求和响应信息, 方便调试.
type LoginResponse ¶
type LoginResponse struct {
CommonResponse
Unionid string `json:"unionid,omitempty"`
Openid string `json:"openid"`
SessionKey string `json:"session_key"`
}
type UserInfo ¶
type UserInfo struct {
UnionId string `json:"unionId,omitempty"`
OpenId string `json:"openId"`
NickName string `json:"nickName"`
Gender int `json:"gender"` // 值为1时是男性,值为2时是女性,值为0时是未知
AvatarUrl string `json:"avatarUrl"`
City string `json:"city"`
Province string `json:"province"`
Country string `json:"country"`
Language string `json:"language"`
Watermark *Watermark `json:"watermark,omitempty"` //数据水印( watermark )
}
微信小程序加密数据结构
func DecryptUserInfo ¶
Click to show internal directories.
Click to hide internal directories.