2

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)
Ibrahim Azhar Armar
  • 25,288
  • 35
  • 131
  • 207

1 Answers1

0

I used this library for iOS which worked perfectly.

https://github.com/jslim89/RSA-Example

Ibrahim Azhar Armar
  • 25,288
  • 35
  • 131
  • 207