$ pri _ key =
$ pub _ key =
$char =' square box'; //Characters to be encrypted
$ sign = $ this-& gt; RsaEncrypt($char,$ pri _ key); //Encrypt the result
$ result = $ this-& gt; RsaDecrypt($sign,$ pub _ key); //Decrypt the encrypted result.
Encryption:
Common function RsaEncrypt($str, $ pri _ key) (
$ pi _ key = OpenSSL _ pkey _ get _ private($ pri _ key);
If (! $pi_key) returns false// The key is not available.
openssl_private_encrypt($str,$encrypted,$ pi _ key);
$ encrypted = base64 _ encode($ encrypted);
Return $ encrypted
}
Decryption:
Public function RsaDecrypt($str, $pub_key){
$ pu _ key = OpenSSL _ pkey _ get _ public($ pub _ key);
If (! $pu_key) returns false// The key is not available.
OpenSSL _ public _ decrypt(base64 _ decode($ str),$decrypted,$ pu _ key);
Return to $ decrypted
}
Note: Open the php _ OpenSSL extension of PHP.