2
votes

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)
1
Seems like this guide should be enough to accomplish what you need. - Ja͢ck
Thanks@Jack let me try this - Ibrahim Azhar Armar
@Ja͢ck, your link helped, thanks. - Ibrahim Azhar Armar

1 Answers

0
votes