收藏
回答

php 支付回调 无法通过 AEAD_AES_256_GCM 解密 ciphertext

//接收到的数据
array(6) {
  ["id"] => string(36) "68edacaf-af7f-5e04-873f-02171b7264da"
  ["create_time"] => string(25) "2024-10-13T13:52:18+08:00"
  ["resource_type"] => string(16) "encrypt-resource"
  ["event_type"] => string(19) "TRANSACTION.SUCCESS"
  ["summary"] => string(12) "支付成功"
  ["resource"] => array(5) {
    ["original_type"] => string(11) "transaction"
    ["algorithm"] => string(16) "AEAD_AES_256_GCM"
    ["ciphertext"] => string(592) "xB33PT/pMsYKcNQht+wIa/mAd+rbY4uQvd3dDU1d213Bv6PZfvqbPj5ADcCubJQMRsLJ2h63wzokx66cDujY3OfMj12pGuL1SJ9h77gpRmtXGCzel7qLCAw1+myv+yW1ZdO0j40ahPJDOqsZgsTF6yN1CrA8F7jDkAFmcFaso8TFAHfFCqzeGbRx41l3rEn+SLqZy0F/MFdhJ8dETHLU7v2IFsdHO/qY8QkRcSVU87gXC0uI/3oY0X8G9J1EOmTa/eXfWeSvWAFbIQ1MaIunQnFAbbK0pSfTrfo0RaU6miSKvk608WWzVmabEsI3veFsDutT9WB89i5UiS1XjVk7e8YJMU2ZSlXaRqsfyafPvMg2R7dm5TAmnflz6ETLqC02oBRzlIt/GSCsKmD5I5q2LhwKXxyJr4iT0sxDlgbMhz/GSHYRdjCOYcHM8TCideScl9xxHm7AwVWrz/IhYGN7wKZpB5GDEjphMXLR0DBC1cWibOw5Nqakdr1Xx6fV7RHB3hL4to1geEPaTmjolAdNEL+DijWzP4xw5qAQUekFQUTtmWLSxd41HqmHOCx3MVPHCDpl2WJlyES9rlo="
    ["associated_data"] => string(11) "transaction"
    ["nonce"] => string(12) "stVEl6Y7KDPb"
  }
}
 
//解密代码
public function jm($key,$nonce,$associated_data,$ciphertext){
        $ciphertext=base64_decode($ciphertext);


        $str = sodium_crypto_aead_aes256gcm_decrypt($ciphertext,$associated_data,$nonce,$key);
        echo($str);
}
//

php 版本是7.3
jm 之后只会输出 false

 apiv3的 key已经确认对的
 但是就是解密不了 只会输出false
回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容