aa
This commit is contained in:
@@ -245,26 +245,32 @@ 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: 密文太短")
|
||||
}
|
||||
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")
|
||||
if string(corpID) != c.SuiteKey {
|
||||
fmt.Println("9")
|
||||
return "", errors.New("ERROR: CorpID匹配不正确")
|
||||
}
|
||||
fmt.Println("222222222222222222222222222222222222")
|
||||
|
||||
Reference in New Issue
Block a user