您可以参考下面的代码进行 AES加密
以及 签名体生成
$key = '54cafa3a6d69c189cf2df3978fbdd435';
$secret = '9b35dd1fd8fb2e8ba4a972122aca50b4';
$account = 'rwvhfu3487@sandbox.com';
$name = 'rwvhfu3487';
$idcard = '923747199405022608';
$phone = '13000000000';
$tax = 1;
$balance = 100;
$remark = "服务费";
$iv = '0000000000000000';
$content = [
'notifyUrl' => 'https://dev.workersaas.com/api/pay/notifyTest',
'taxFundId' => 1,
'month' => '2024-07',
'outerTradeNo' => sha1(time().rand(1000,9999)),
'empName' => $name,
'empPhone' => $phone,
'licenseType' => 'ID_CARD',
'licenseId' => $idcard,
'settleType' => 'alipay',
'payAccount' => $account,
'positionName' => $remark,
'payAmount' => $balance,
];
$time = time();
$content = json_encode($content);
$model = 'AES-256-CBC';
$encode = urlencode(base64_encode(openssl_encrypt($content, $model, $secret, OPENSSL_RAW_DATA, $iv)));
// echo $content.PHP_EOL.PHP_EOL;
// echo $encode.PHP_EOL.PHP_EOL;
$version = 100000;
$postArr = [
'plat' => 'api',
'version' => $version,
'access_key' => $key,
'timestamp' => $time,
'content' => $encode
];
$str = "access_key=".$key."&content=".$encode."&plat=api×tamp=".$time."&version=".$version;
$signSource = $secret.$time.$str;
// echo $signSource.PHP_EOL.PHP_EOL;
$sign = md5($signSource);
// echo $sign.PHP_EOL.PHP_EOL;
$postArr['signature']= $sign;
echo json_encode($postArr);