This commit is contained in:
laodaming 2023-11-07 13:27:29 +08:00
parent e791002e2e
commit 2e47d654be

View File

@ -6,7 +6,6 @@ import (
"crypto/cipher"
"crypto/sha256"
"encoding/base64"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
@ -146,12 +145,6 @@ func (l *WebhookLogic) CalculateFeiShuWebhookSignature(timestamp, nonce, encrypt
// 解密事件消息
func (l *WebhookLogic) DecryptFeiShuWebhookMsg(encrypt string, encryptKey string) ([]byte, error) {
h := sha256.New()
_, err := h.Write([]byte(encryptKey))
if err != nil {
return nil, err
}
key := hex.EncodeToString(h.Sum(nil))
buf, err := base64.StdEncoding.DecodeString(encrypt)
if err != nil {
return nil, fmt.Errorf("base64StdEncode Error[%v]", err)
@ -159,7 +152,7 @@ func (l *WebhookLogic) DecryptFeiShuWebhookMsg(encrypt string, encryptKey string
if len(buf) < aes.BlockSize {
return nil, errors.New("cipher too short")
}
keyBs := sha256.Sum256([]byte(key))
keyBs := sha256.Sum256([]byte(encryptKey))
block, err := aes.NewCipher(keyBs[:sha256.Size])
if err != nil {
return nil, fmt.Errorf("AESNewCipher Error[%v]", err)