.Net and IOS both support PKCS7Padding, but Java doesn't (unless use some third-party library)
.Net and Java both support ISO10126Padding, but IOS doesn't (unless use some third-patry library)
So I think you need to have separate .net encryption code for IOS and Java.
Here are some code examples:
for IOS:
+ (NSData*)encryptData:(NSData*)data :(NSData*)key :(NSData*)iv { size_t bufferSize = [data length]*2; void *buffer = malloc(bufferSize); size_t encryptedSize = 0; CCCryptorStatus cryptStatus = CCCrypt(kCCEncrypt, kCCAlgorithmAES128, kCCOptionPKCS7Padding, [key bytes], [key length], [iv bytes], [data bytes], [data length], buffer, bufferSize, &encryptedSize); if (cryptStatus == kCCSuccess) return [NSData dataWithBytesNoCopy:buffer length:encryptedSize]; else free(buffer); return NULL; }
for .NET:
public static byte[] AesEncrypt(byte[] bytes, byte[] key, byte[] iv) { if (bytes == null || bytes.Length == 0 || key == null || key.Length == 0 || iv == null || iv.Length == 0) throw new ArgumentNullException(); using (var memoryStream = new MemoryStream()) { using (var rijndaelManaged = new RijndaelManaged { Key = key, IV = iv, Padding = PaddingMode.PKCS7, Mode = CipherMode.CBC }) { using (var cryptoStream = new CryptoStream(memoryStream, rijndaelManaged.CreateEncryptor(key, iv), CryptoStreamMode.Write)) { cryptoStream.Write(bytes, 0, bytes.Length); } } return memoryStream.ToArray(); } }
for Java:
public static byte[] encrypt(byte[] bytes, byte[] key, byte[] iv) throws Exception { Cipher cipher = Cipher.getInstance("AES/CBC/ISO10126Padding"); cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "AES"), new IvParameterSpec(iv)); return cipher.doFinal(bytes); }
I only provide the code for encryption because decryption code is very similar and you can figure it out easily.
Any more question please leave comments.