This commit is contained in:
suyl
2021-08-17 14:53:35 +08:00
parent 9f92a140d4
commit 53a12a47b6

View File

@@ -130,7 +130,6 @@ func (a *API) Decrypt(sign, timestr, nonce, msg string) (decryptedMsg string, er
// }
//}
c := NewDingTalkCrypto(a.GetCallbackToken(), string(a.GetCallbackAESKey()), a.corpID)
fmt.Println("1111111111111111111111111111111111111111111111111111")
return c.GetDecryptMsg(sign, timestr, nonce, msg)
}
@@ -246,13 +245,16 @@ func NewDingTalkCrypto(token, encodingAESKey, suiteKey string) *DingTalkCrypto {
}
func (c *DingTalkCrypto) GetDecryptMsg(signature, timestamp, nonce, secretMsg string) (string, error) {
if !c.VerificationSignature(c.Token, timestamp, nonce, secretMsg, signature) {
fmt.Println("33333333333333333333333333333")
return "", errors.New("ERROR: 签名不匹配")
}
decode, err := base64.StdEncoding.DecodeString(secretMsg)
if err != nil {
fmt.Println("1111111111111111111111", err)
return "", err
}
if len(decode) < aes.BlockSize {
fmt.Println("2222222222222222222222222222222", err)
return "", errors.New("ERROR: 密文太短")
}
blockMode := cipher.NewCBCDecrypter(c.Block, c.BKey[:c.Block.BlockSize()])