Home:ALL Converter>AES Encryption with Android, iOS and pHp

AES Encryption with Android, iOS and pHp

Ask Time:2016-07-12T16:10:15         Author:Syed Asad Abbas Zaidi

Json Formatter

I'm using "FBEncryptorAES" library for encryption in Obj-C iOS The encrypted data from a string and the decrypted data vales are perfect. But when I try to decrypt using the following online tool: http://aesencryption.net/ ,the encryption and decryption do not match.

And the response from the backend server is success while using Android but in iOS response is failure.

Can anyone suggest some library for iOS that work exactly as the Android code is working and encrypting data.

Android Code:

public static String encrypt(String input, String key) {
    try {
        SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes(), "AES");
        Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
        cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec);

        return new String(Base64.encode(cipher.doFinal(input.getBytes()),Base64.DEFAULT));
    } catch (Exception e) {

    }
    return null;
}

Author:Syed Asad Abbas Zaidi,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/38323283/aes-encryption-with-android-ios-and-php
yy