I am using AES encrypting with bouncy castle implementation in both Android and in a Java servlet environment. The encryption part is ok in both scenario. However I get different result for those 2 platforms once I encrypt the same text with same key.
My intention is to do an encryption in Android and do the decryption in web environment.
This is the only change I have done for Android AES implementation.
    KeyGenerator kgen = KeyGenerator.getInstance("AES");
    SecureRandom sr = null;
    if (android.os.Build.VERSION.SDK_INT >= JELLY_BEAN_4_2) {
        sr = SecureRandom.getInstance("SHA1PRNG", "Crypto");
    } else {
        sr = SecureRandom.getInstance("SHA1PRNG");
    }
    sr.setSeed(key);
    kgen.init(128, sr);
    SecretKey skey = kgen.generateKey();
    byte[] raw = skey.getEncoded();
Above I just add the Crypto into get instance.
I used the spongy castle implementation as well to see whether I can accomplish this. Still it gave me the same result as Android gives. Not sure whether I have loaded it properly. I tested this on API level 14 and 17.
This leads to javax.crypto.BadPaddingException: pad block corrupted.