Why Aes Java Decryption Return Extra Characters?
Excuse me for bad English. i use mcrypt which i get it from here MCrypt for php and java. in my android application i need php and java communicate securely so i get above mentione
Solution 1:
AES encrypt in blocks of 16 bytes. If your input ain't a multiple of 16 bytes, a padding scheme is needed. As you have not specified any padding option for Mcrypt, it uses "zero padding".
In your Java code you specify "NoPadding" when you instantiate your Cipher:
cipher = Cipher.getInstance("AES/CBC/NoPadding");
So Java considers the padding done by php to be part of the encrypted data.
You just need to ensure that your php and Java code uses the same padding scheme.
Solution 2:
I think this is binary data which can not be displayed. Have you tried to use base64 to convert it to a regular string before sending it to the php script?
In the php script then you do following to decode the base64 string.
$data=base64_decode($data["request"])
Post a Comment for "Why Aes Java Decryption Return Extra Characters?"