PHP 7.2 moved completely away from Mcrypt
and the encryption now is based on the maintainable Libsodium
library.
All your encryption needs can be basically resolved through Libsodium
library.
// On Alice's computer:
$msg = 'This comes from Alice.';
$signed_msg = sodium_crypto_sign($msg, $secret_sign_key);
// On Bob's computer:
$original_msg = sodium_crypto_sign_open($signed_msg, $alice_sign_publickey);
if ($original_msg === false) {
throw new Exception('Invalid signature');
} else {
echo $original_msg; // Displays "This comes from Alice."
}
Libsodium documentation: https://github.com/paragonie/pecl-libsodium-doc