I've got this code to decrypt a php (mcrypt) token.
The problem is, that the decode method always uses Rijndael-128 not -256. When I encode on the php side with -128, I can decode in Android. When using 256 its not working. (getHash returns a SHA-256 hashed key):
String key = "987654321";
SecretKeySpec keyspec = new SecretKeySpec(getHash(key), "AES");
Cipher cipherDecode = Cipher.getInstance("AES/ECB/ZeroBytePadding");
byte[] text = Base64.decode(
"wdRe00YxTFGQ65QmWukPxFLlZRSPqmRY8tHufikBHW0=",
Base64.DEFAULT);
cipherDecode.init(Cipher.DECRYPT_MODE, keyspec);
final byte[] decrypted = cipherDecode.doFinal(text);
String decyptedText = new String(decrypted);
This should give the Text 'wdRe00YxTFGQ65QmWukPxFLlZRSPqmRY8tHufikBHW0=', but it doesn't.
How can I specifiy or force the correct code to be used?