From f4b2e657907ac3fdcde35a58f2e6e931f433f69a Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Tue, 17 Aug 2021 15:01:15 +0800 Subject: [PATCH] aa --- platformapi/dingdingapi/callback.go | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/platformapi/dingdingapi/callback.go b/platformapi/dingdingapi/callback.go index 8c4793d7..4485563d 100644 --- a/platformapi/dingdingapi/callback.go +++ b/platformapi/dingdingapi/callback.go @@ -218,6 +218,8 @@ func (a *API) GetCallbackMsg(formMap map[string]interface{}, bodyData []byte) (m if descryptMsg, err = a.Decrypt(formMap["signature"].(string), formMap["timestamp"].(string), formMap["nonce"].(string), encrypt); err == nil { baseapi.SugarLogger.Debugf("dingding GetCallbackMsg descryptMsg:%s", descryptMsg) err = utils.UnmarshalUseNumber([]byte(descryptMsg), &msgMap) + } else { + fmt.Println("err ", err) } } return msgMap, a.Err2CallbackResponse(err) @@ -226,14 +228,8 @@ func (a *API) GetCallbackMsg(formMap map[string]interface{}, bodyData []byte) (m } func NewDingTalkCrypto(token, encodingAESKey, suiteKey string) *DingTalkCrypto { - bkey, err := base64.StdEncoding.DecodeString(encodingAESKey + "=") - if err != nil { - fmt.Println("111111111111111", err) - } - block, err := aes.NewCipher(bkey) - if err != nil { - fmt.Println("22222222222222222", err) - } + bkey, _ := base64.StdEncoding.DecodeString(encodingAESKey + "=") + block, _ := aes.NewCipher(bkey) c := &DingTalkCrypto{ Token: token, EncodingAESKey: encodingAESKey, @@ -254,26 +250,17 @@ func (c *DingTalkCrypto) GetDecryptMsg(signature, timestamp, nonce, secretMsg st if len(decode) < aes.BlockSize { return "", errors.New("ERROR: 密文太短") } - fmt.Println("1") blockMode := cipher.NewCBCDecrypter(c.Block, c.BKey[:c.Block.BlockSize()]) - fmt.Println("2") plantText := make([]byte, len(decode)) - fmt.Println("3") blockMode.CryptBlocks(plantText, decode) - fmt.Println("4") plantText = pkCS7UnPadding(plantText) - fmt.Println("5") size := binary.BigEndian.Uint32(plantText[16:20]) - fmt.Println("6") plantText = plantText[20:] - fmt.Println("7") corpID := plantText[size:] - fmt.Println("8") + fmt.Println("222222222222222222222222222222222222", string(plantText[:size])) if string(corpID) != c.SuiteKey { - fmt.Println("9") return "", errors.New("ERROR: CorpID匹配不正确") } - fmt.Println("222222222222222222222222222222222222") return string(plantText[:size]), nil }