1. 首先通过java程序将建设银行的公钥串转成pem格式并写入文件
SignTest.java是运行程序, RSASig.java是建设银行签名算法类, bcprov-jdk15-145.jar是PEMWriter类库
2. php程序做签名验证
<?php
$data = "POSID=000000000&BRANCHID=330000000&ORDERID=2004010061&PAYMENT=0.01&CURCODE=01&REMARK1=&REMARK2=&SUCCESS=N";
$sign = "5bf88c409a13963286904e8954a4d825108f9b5bb60a8c8e5cfc05355fe4e247c777b521c7d68b8d51968285d51d1a0da0c5bd55e19268949a20dd7bd14f17422e41f3e6f7446d2136e10e796abc8b8a6f752bed5091374551d84d02f185aa3f9b516ac77ca319b06a8269389de6d7f677c619bfc0c89ccbcb125ae6dd7cc646";
$public_key="pubkey.pem";
$fp = fopen($public_key, "r");
$public_key = fread($fp, 8192);
fclose($fp);
$pkeyid = openssl_get_publickey($public_key);
$verifyResult = openssl_verify($data, pack("H",$sign),$pkeyid,OPENSSL_ALGO_MD5);
openssl_free_key($pkeyid);
echo $verifyResult;
?>