mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-04 12:52:27 +08:00
@@ -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 {
|
||||
|
||||
12
util/http.go
12
util/http.go
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user