Skip to content

Commit

Permalink
修复小程序授权信息解密
Browse files Browse the repository at this point in the history
  • Loading branch information
shenghui0779 committed Aug 15, 2024
1 parent d710b9f commit ac0eab6
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions wechat/miniprogram.go
Original file line number Diff line number Diff line change
Expand Up @@ -645,22 +645,15 @@ func (mp *MiniProgram) DecodeEncryptData(sessionKey, iv, encryptData string) ([]
if err != nil {
return nil, fmt.Errorf("session_key base64.decode error: %w", err)
}

ivBlock, err := base64.StdEncoding.DecodeString(iv)
if err != nil {
return nil, fmt.Errorf("iv base64.decode error: %w", err)
}

data, err := base64.StdEncoding.DecodeString(encryptData)
if err != nil {
return nil, fmt.Errorf("encrypt_data base64.decode error: %w", err)
}

ct, err := xcrypto.AESEncryptCBC(keyBlock, ivBlock, data)
if err != nil {
return nil, err
}
return ct.Bytes(), nil
return xcrypto.AESDecryptCBC(keyBlock, ivBlock, data)
}

// DecodeEventMsg 解析事件消息,使用:msg_signature、timestamp、nonce、msg_encrypt
Expand Down

0 comments on commit ac0eab6

Please sign in to comment.