How to do RSA-2048 Encryption

I would like to do the similar encryption in the iOS


KeyFactory keyFactory = KeyFactory.getInstance("RSA");

RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(modulus, pubExp);

RSAPublicKey key = (RSAPublicKey) keyFactory.generatePublic(pubKeySpec);

Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");

cipher.init(Cipher.ENCRYPT_MODE, key);

byte[] cipherData = cipher.doFinal(value.getBytes());

strEncryInfoData = new String(org.apache.commons.codec.binary.Base64.encodeBase64(cipherData));

Replies

You should look at the CryptoCompatibility sample code, which shows how to do various forms of encryption in a way that’s compatible with other common crypto toolkits.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"