1
0
mirror of https://github.com/silenceper/wechat.git synced 2026-02-04 12:52:27 +08:00

update golangci (#349)

* update golangci
This commit is contained in:
silenceper
2020-11-26 12:25:57 +08:00
committed by GitHub
parent 185baa5d12
commit c0da806e03
9 changed files with 38 additions and 34 deletions

View File

@@ -20,7 +20,7 @@ const (
SignTypeHMACSHA256 = `HMAC-SHA256`
)
//EncryptMsg 加密消息
// EncryptMsg 加密消息
func EncryptMsg(random, rawXMLMsg []byte, appID, aesKey string) (encrtptMsg []byte, err error) {
defer func() {
if e := recover(); e != nil {
@@ -38,7 +38,7 @@ func EncryptMsg(random, rawXMLMsg []byte, appID, aesKey string) (encrtptMsg []by
return
}
//AESEncryptMsg ciphertext = AES_Encrypt[random(16B) + msg_len(4B) + rawXMLMsg + appId]
// AESEncryptMsg ciphertext = AES_Encrypt[random(16B) + msg_len(4B) + rawXMLMsg + appId]
//参考github.com/chanxuehong/wechat.v2
func AESEncryptMsg(random, rawXMLMsg []byte, appID string, aesKey []byte) (ciphertext []byte) {
const (
@@ -76,7 +76,7 @@ func AESEncryptMsg(random, rawXMLMsg []byte, appID string, aesKey []byte) (ciphe
return
}
//DecryptMsg 消息解密
// DecryptMsg 消息解密
func DecryptMsg(appID, encryptedMsg, aesKey string) (random, rawMsgXMLBytes []byte, err error) {
defer func() {
if e := recover(); e != nil {

View File

@@ -52,9 +52,9 @@ func PostJSON(uri string, obj interface{}) ([]byte, error) {
if err != nil {
return nil, err
}
jsonData = bytes.Replace(jsonData, []byte("\\u003c"), []byte("<"), -1)
jsonData = bytes.Replace(jsonData, []byte("\\u003e"), []byte(">"), -1)
jsonData = bytes.Replace(jsonData, []byte("\\u0026"), []byte("&"), -1)
jsonData = bytes.ReplaceAll(jsonData, []byte("\\u003c"), []byte("<"))
jsonData = bytes.ReplaceAll(jsonData, []byte("\\u003e"), []byte(">"))
jsonData = bytes.ReplaceAll(jsonData, []byte("\\u0026"), []byte("&"))
body := bytes.NewBuffer(jsonData)
response, err := http.Post(uri, "application/json;charset=utf-8", body)
if err != nil {
@@ -75,9 +75,9 @@ func PostJSONWithRespContentType(uri string, obj interface{}) ([]byte, string, e
return nil, "", err
}
jsonData = bytes.Replace(jsonData, []byte("\\u003c"), []byte("<"), -1)
jsonData = bytes.Replace(jsonData, []byte("\\u003e"), []byte(">"), -1)
jsonData = bytes.Replace(jsonData, []byte("\\u0026"), []byte("&"), -1)
jsonData = bytes.ReplaceAll(jsonData, []byte("\\u003c"), []byte("<"))
jsonData = bytes.ReplaceAll(jsonData, []byte("\\u003e"), []byte(">"))
jsonData = bytes.ReplaceAll(jsonData, []byte("\\u0026"), []byte("&"))
body := bytes.NewBuffer(jsonData)
response, err := http.Post(uri, "application/json;charset=utf-8", body)