openssl
header("content-Type: text/html; charset=UTF-8"); $private = '-----BEGIN RSA PRIVATE KEY----- MIICXQIBAAKBgQDn36LGQvqZMB0AH4IIw6QYLChRr7I2V3BWcAUU42rB/RlYvOoE bpyOnf8c5+r2RsspVXA0ldp77Ph5DH2e9GzBrFzHe6Z7aW8ipXo/PU8BKEIV5Kk4 xSyJ0C5EeuKXThO4FJCrU7nJAcRB4nlbvKn5ZkLJ5kjgWbQodzS1nG0bxwIDAQAB AoGBAJ2mETeXJmasrar9wR1QVusQasFPIW2M+ZXrR6kyDc2i1W7d0oX85niYt3Dh xYB4FX0e19EI6alELpOuiGJgcOfZeckyIsOTuDuSj4DLkWDu9/V/Xe5ydop6sNnM Qe7PSati7um/JkyEJ8bLIsbtR89ciNgBEmNV5IuOJcPYTznxAkEA+G1AKxs7BoSy doXcQqvkz2ayuzsNCnurDTlZXM+LOkqw60kY8LS8EClC6yS8udyfHfftfivIoXQU 2jWMwSzHlQJBAO7xM80Uarz1IOqaJJE1ovJMQdq2FI/WLMOyKp6w0azB5l//DOwx 2sACmgP+5o0lLvXwFPDuMm8RLMv5b/LYzusCQQCCsn+S7iWUnVWCs5QY43RihSY9 CKkovb1VHLnd8TbPeSIw9ukPIhba7cpOCarcoax4yMoCmihYgMjDsG6X5uYtAkBu 9a/akpqmuSbaC07j6AaNgoAqctfFm+4Zyskj/HTCRyEWfzifDt/IvuyK4npqHVRb fWwcHmFpVo55ApLMMYaVAkBHO367nRADOUfU7l7yTR0DQa+7gsFhceVys6uIscDv 3xgGg7U8t9N93I37UmA9xRYDCggjqeeUte4lgwFdm1PP -----END RSA PRIVATE KEY-----'; $public_key = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDn36LGQvqZMB0AH4IIw6QYLChR r7I2V3BWcAUU42rB/RlYvOoEbpyOnf8c5+r2RsspVXA0ldp77Ph5DH2e9GzBrFzH e6Z7aW8ipXo/PU8BKEIV5Kk4xSyJ0C5EeuKXThO4FJCrU7nJAcRB4nlbvKn5ZkLJ 5kjgWbQodzS1nG0bxwIDAQAB'; $data = 'body=西安市莲湖区家艺鲜水果店&is_raw=1&mch_create_ip=119.61.18.42&mch_id=102575538650&nonce_str=jvmperv23jon7r3hzyqm8cnd0fzdmiel¬ify_url=https://mall.epaikj.com/wap/paynotice.php&out_trade_no=20180226163453185983&service=pay.weixin.jspay&sub_appid=wx7941ffea4379e027&sub_openid=oa21fw298nFUzDlUkpA_mN8BjaP8&total_fee=610'; $res = openssl_get_privatekey($private); openssl_sign($data, $sign, $res, OPENSSL_ALGO_SHA256); openssl_free_key($res); $sign = base64_encode($sign); //echo $sign; $pkeyid = openssl_pkey_get_public($public_key); $verify = (bool)openssl_verify($data, base64_decode($sign), $pkeyid, OPENSSL_ALGO_SHA256); openssl_free_key($pkeyid); var_dump($verify);