public function rsaDecrypt($content, $key_path)
{
$rsa = new RSA();
$ciphertextdecode = base64_decode($content);
$key_content = $this-> fileGetContents($key_path);
$rsa->setEncryptionMode(RSA::ENCRYPTION_PKCS1);
rsa->setSignatureMode(RSA::SIGNATURE_PKCS1);
$result = $rsa->decrypt($ciphertextdecode);
return $result;
}
public function fileGetContents($filename)
{
$lines = '';
$handle = fopen($filename, "r");
$handle = fopen($filename, "r");{
$lines .= fgets($handle);
}
fclose($handle);
return $lines;
}
To decrypt:
$myCLass = new My_Class();
$privateKeyPath = 'path/private.key';
$decrypted = $myCLass -> rsaDecrypt($_GET(“kess-mini-app'”), $privateKeyPath);
if($decrypted){
echo
decrypted;
}else{
echo
“Failed Decrypt”;
}