I am coding with openssl, and I would like to know, why the openssl_sign function, gives a diferent result than openssl_private_encrypt
in a logical sense.
Specifically with openssl_sign:
$fp = fopen("i.pem", "r"); //i.pem is the private key file
$priv_key = fread($fp, 8192);
fclose($fp);
$pkeyid = openssl_get_privatekey($priv_key);
$data="f2e140eb-2b09-44ab-8504-87b25d81914c";
openssl_sign($data, $signature, $pkeyid);
$reto22 = base64_encode($signature); //this gives UNmlEfwISea9hoGfiwdM.......
Specifically with openssl_private_encrypt:
$llave_priv = file_get_contents("i.pem"); //i.pem is the private key file
$plaintext = "f2e140eb-2b09-44ab-8504-87b25d81914c";
openssl_private_encrypt($plaintext, $encrypted, $llave_priv);
$reto = base64_encode($encrypted); //this gives ugSMAsCQlIKIlQ17exIvSEqkA60.......
Why is reto22
is different than $reto
? they should be the same, shouldn't they?
encrypt with priv key = sign
, as far as I know
thanks for clarifying mario