我必须在php 4中维护一个必须通过openssl_sign发送签名数据的应用程序。问题是对于相同大小的不同数据,签名总是相同的。 例如。这段代码:
$signature = null;
$message1 = 'foobar';
$privkey1 = openssl_pkey_get_private('file://path/to/private/key/privkey1.pem');
while ($msg = openssl_error_string()) {
echo $msg . "<br />\n";
}
openssl_sign($message1, $signature, $privkey1);
while ($msg = openssl_error_string()) {
echo $msg . "<br />\n";
}
openssl_free_key($privkey1);
while ($msg = openssl_error_string()) {
echo $msg . "<br />\n";
}
$signature2 = null;
$message2 = 'foobaz';
$privkey2 = openssl_pkey_get_private('file://path/to/private/key/privkey1.pem');
while ($msg = openssl_error_string()) {
echo $msg . "<br />\n";
}
openssl_sign($message2, $signature2, $privkey2);
while ($msg = openssl_error_string()) {
echo $msg . "<br />\n";
}
openssl_free_key($privkey2);
while ($msg = openssl_error_string()) {
echo $msg . "<br />\n";
}
echo base64_encode($signature) . '<br/>';
echo base64_encode($signature2) . '<br/>';
输出:
uANYD6qKuvlcyK2svarB0ESPO7qLa75cEIhCmjkTF23cwveSE + Mxuhsl7JKjOEOPf7v8mCoTLmdlm / 2RDD0Nabdpi + 5Ez8Di8dFNpXtMVRByJvewOOGxTgYt / 1XPIqe + dvLunkqtl8dHkRhtzuBHay1suco53Ybs7r41YKdqnkk =
uANYD6qKuvlcyK2svarB0ESPO7qLa75cEIhCmjkTF23cwveSE + Mxuhsl7JKjOEOPf7v8mCoTLmdlm / 2RDD0Nabdpi + 5Ez8Di8dFNpXtMVRByJvewOOGxTgYt / 1XPIqe + dvLunkqtl8dHkRhtzuBHay1suco53Ybs7r41YKdqnkk =
有谁知道这个问题的原因是什么?