PGP encryption - PHP openssl

I have this RSA 2048 key in the local key.key file:

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.11 (GNU/Linux)

...
...
...
-----END PGP PUBLIC KEY BLOCK-----

How can I use it in PHP to encrypt a string to send? I am in a co-hosting environment and I cannot install GNUpg, so I decided that the included OpenSSL features are the way to go.

I tried this, but I get "... the key parameter is not a valid public key ..."

<?php

$text = 'hello jeremy how are you';
$key = openssl_pkey_get_public(chunkfile_get_contents('key.key')); 

openssl_public_encrypt($text, $encrypted, $key);
echo $crypted;
exit;
+4
source share
1 answer

OpenSSL OpenPGP, . PHP GnuPG PHP GnuPG module, , PGP PHP?. GnuPG , PHP, , , ( ).

OpenPGP, GnuPG , , GnuPG, -.

+4

Source: https://habr.com/ru/post/1569460/


All Articles