I already read a lot of topics in this forum and many other threads on the web but I couldn't find a satisfactory answer....
Even knowing that I can get a negative point I need to put this question...
I have several webservices written in java. And until now, just Android apps are consuming this services. Most of all the SOAP messages are encrypted, and I use this class below on both sides (Android and Server), to encrypt and decrypt:
public class Crypto {
private static final String engine = "AES";
private static final String crypto = "AES/CBC/PKCS5Padding";
static String key = "1234567890987654";
static String _iv = "1234567890987654";
public static byte[] cipher(byte[] data, int mode)
throws NoSuchAlgorithmException, NoSuchPaddingException,
InvalidKeyException, IllegalBlockSizeException,
BadPaddingException, InvalidAlgorithmParameterException
{
SecretKeySpec sks = new SecretKeySpec(key.getBytes(), engine);
IvParameterSpec iv = new IvParameterSpec(_iv.getBytes());
Cipher c = Cipher.getInstance(crypto);
c.init(mode, sks, iv);
return c.doFinal(data);
}
public static byte[] encrypt(byte[] data) throws InvalidKeyException,
NoSuchAlgorithmException, NoSuchPaddingException,
IllegalBlockSizeException, BadPaddingException,
InvalidAlgorithmParameterException {
return cipher(data, Cipher.ENCRYPT_MODE);
}
public static byte[] decrypt(byte[] data) throws InvalidKeyException,
NoSuchAlgorithmException, NoSuchPaddingException,
IllegalBlockSizeException, BadPaddingException,
InvalidAlgorithmParameterException {
return cipher(data, Cipher.DECRYPT_MODE);
}
}
And all this works very well. I'm not interested if this is a good approach, but that's enough for me.
The case now, is that I must write some iOS apps that will consume these webservices, and I must to know how to use the same cryptography in Objective-C, or a cryptography that I can apply on Android, iOS and server side.
I thank you so much and appreciate any tip!
If you are looking for a cross language encryptor/ decryptor I would suggest looking here: RNCryptor
If you are looking at Encryption technologies provided by Apple then this link would be a good place to start.
If you are looking for Objective C code to use as a reference point while encrypting. I would suggest looking at this AES 128 Encryption Object C project on github .
Finally, this previous question may help you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.