起因:需要调用Java后台写的接口,接口sdk需要携带签名sign,签名方法是sha1withrsa
主要是格式问题
$sercet = "一行格式的字符串秘钥";
/**
* 获取SHA1签名
*/
public function getSign($paramsStr,$sercet)
{
$signature = "";
$str = chunk_split( $sercet, 64, "\n" );
$key = "-----BEGIN RSA PRIVATE KEY-----\n$str-----END RSA PRIVATE KEY-----\n";
openssl_sign( $paramsStr ,$signature ,$key );
return base64_encode($signature);
}