I have a string encrypted in PHP using following code
function encrypt($string, $publicKey)
{
openssl_public_encrypt($string, $cryptedText, $publicKey);
return base64_encode($cryptedText);
}
$publicKey = file_get_contents('public.crt');
$encryptedText = encrypt('Test', $publicKey);
This works fine in PHP, i am able to encrypt/decrypt using public/private key pair.
The encryptedText is sent to iOS application where i want to decrypt the same string, i tried with multiple approaches and nothing seems to be working, any pointer to do the following is appreciated.
- Decrypt OpenSSL encrypted string received from PHP in Objective-C
- Encrypt and send data to PHP for Decrypting (should support openssl_private_decrypt)