In my iOS library, I have a Base64 encoded string containing the X.509 RSA 2048 bit public key. I want to encrypt a string using this public key. Can anyone please provide some Objective C code reference, mentioning the libraries I need to include?
The equivalent java code looks as below:
byte[] keyBytes = Base64.decodeBase64(publicKeyData); / X509EncodedKeySpec rsaPublicKeySpec = new X509EncodedKeySpec(keyBytes); KeyFactory fact = KeyFactory.getInstance("RSA"); PublicKey publicKey = fact.generatePublic(rsaPublicKeySpec); Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding"); cipher.init(Cipher.ENCRYPT_MODE, pubKey); encryptedData = cipher.doFinal(dataToEncrypt);