Answer the question
In order to leave comments, you need to log in
How to get the same result in PHP as in OpenSSL?
Friends, good day!
There is a set of data from which it is necessary to calculate hash > encrypt them with a private key > encode in base64.
There are no problems in OpenSSL, everything works for hours and is tested on the host:
openssl.exe dgst -sha256 -sign privateKey.pem -out sign.txt data.txt
openssl.exe base64 -e -in sign.txt -out sign64.txt
$hash = hash_file('sha256', 'data.txt');
openssl_private_encrypt($hash, $encrypted, $privateKey);
echo base64_encode($encrypted);
Answer the question
In order to leave comments, you need to log in
https://stackoverflow.com/questions/34496764/php-i...
$data = file_get_contents("data");
$pkeyid = openssl_pkey_get_private("file://key.pem");
openssl_sign($data, $signature, $pkeyid, OPENSSL_ALGO_SHA256);
openssl_free_key($pkeyid);
print base64_encode($signature);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question