Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Machunan

macrumors newbie
Original poster
Dec 17, 2016
1
0
Is there any iOS alternative available for below Android Code
public static String EncryptString(String value, String mod, String exp) {
String strEncryInfoData = "";
try {
BigInteger modulus = new
color:black">BigInteger(mod, 10);
BigInteger pubExp = new
color:black">BigInteger(exp, 10);

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));


} catch
(Exception e) {
e.printStackTrace();
}
String result = strEncryInfoData.replaceAll("(\\r|\\n)", "");
int count =result.length() ;
return result;
}
 
Is there any iOS alternative available for below Android Code
public static String EncryptString(String value, String mod, String exp) {
String strEncryInfoData = "";
try {
BigInteger modulus = new
color:black">BigInteger(mod, 10);
BigInteger pubExp = new
color:black">BigInteger(exp, 10);

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));


} catch
(Exception e) {
e.printStackTrace();
}
String result = strEncryInfoData.replaceAll("(\\r|\\n)", "");
int count =result.length() ;
return result;
}
Code:
public static String EncryptString(String value, String mod, String exp) {
String strEncryInfoData = "";
    try {
        BigInteger modulus = new
color:black">BigInteger(mod, 10);
        BigInteger pubExp = new
color:black">BigInteger(exp, 10);

        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));


    } catch
(Exception e) {
        e.printStackTrace();
    }
    String result = strEncryInfoData.replaceAll("(\\r|\\n)", "");
    int count =result.length() ;
    return result;
}

The menu bar at the top has a '+' button, that has an 'add code' option. If you post code, plz use the add code option to make it easy to read.

I'm pretty sure iOS has all the encryption that Andoid has, you can also write in c/c++/ObjC/Swift. All kinds of encryption.

Apple does have rules about what encryption can be used, IIRC they have a process to go thru.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.