A
A
Alexey Denisov2021-03-30 00:21:26
PHP
Alexey Denisov, 2021-03-30 00:21:26

Openssl - how to use your PrivateKey?

There is a working example of RSA encryption

<?php
$key = <<<SOMEDATA777
-----BEGIN RSA PRIVATE KEY-----
MIIBPQIBAAJBALqbHeRLCyOdykC5SDLqI49ArYGYG1mqaH9/GnWjGavZM02fos4l
c2w6tCchcUBNtJvGqKwhC5JEnx3RYoSX2ucCAwEAAQJBAKn6O+tFFDt4MtBsNcDz
GDsYDjQbCubNW+yvKbn4PJ0UZoEebwmvH1ouKaUuacJcsiQkKzTHleu4krYGUGO1
mEECIQD0dUhj71vb1rN1pmTOhQOGB9GN1mygcxaIFOWW8znLRwIhAMNqlfLijUs6
rY+h1pJa/3Fh1HTSOCCCCWA0NRFnMANhAiEAwddKGqxPO6goz26s2rHQlHQYr47K
vgPkZu2jDCo7trsCIQC/PSfRsnSkEqCX18GtKPCjfSH10WSsK5YRWAY3KcyLAQIh
AL70wdUu5jMm2ex5cZGkZLRB50yE6rBiHCd5W1WdTFoe
-----END RSA PRIVATE KEY-----
SOMEDATA777;
$data = "JutBa0GLHzGrlygxwWr66cizw4W4za+DbzZweNM0iloCD7xEP9LclL013lcksJL5XhjW44U+oxpq cX1ZSLhWuA==";

$pk  = openssl_get_privatekey($key);
openssl_private_decrypt(base64_decode($data), $out, $pk);
echo $out;
?>


How can you use your keys, such as A137DCBC5317D0A15 , in the form of HEX data, You
need to encrypt a string in PHP

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SKEPTIC, 2021-03-30
@pro100chel

The key in the example is in string format. What prevents hex from being translated into a string? Moreover, you already asked this question a year ago . How to convert hex to a string?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question