flex3 – How can I use CBC mode in Android?-ThrowExceptions

Exception or error:

I want to convert below FLEX code to Android/Java


var cbc:CBCMode = new CBCMode(new AESKey(keyByteArray), Crypto.getPad("pkcs5"));
                cbc.IV = Hex.toArray(ivHex);
                var msgByteArray:ByteArray = new ByteArray();
                msgByteArray = Hex.toArray(encHex);


SecretKeySpec skey = new SecretKeySpec(byteArray, “AES”);

   // Cipher ci = Cipher.getInstance("AES/CBC/PKCS5Padding");
   /* ci.init(DECRYPT_MODE, skey, new IvParameterSpec(Hex.decode(first16BitResult)));
    byte[] decrypted = ci.doFinal(Hex.decode(after16BitResult));

    Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");

// cipher.init(DECRYPT_MODE, skey, new IvParameterSpec(Hex.decode(after16BitResult)));

 //   InflaterInputStream inflaterStream =new InflaterInputStream(new CipherInputStream(new ByteArrayInputStream(Hex.decode(first16BitResult)), cipher));
  //  return IOUtils.toByteArray(inflaterStream);
How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *