I am new for AES encryption methodology and try to implement encrypt data at the client end and decrypt data at the server end.
What I have done so far is, I have implemented client portal in java and server scripts in PHP. I define AES-key, salt and I encrypt data in the client end(In-JAVA) with the help of AES-key and salt. Now, I am calling an API with parameter key, salt and data to the server(php script) and try to decrypt the data. I am using phpseclib
lib for decrypt the data.
I have sample decrypt
function as below. (Note:- I already decode with base64_decode this key, salt and data before sending to this function)
public function decryptAES($data,$key,$salt){
$cipher = new Crypt_AES(CRYPT_MODE_CBC);
$ivsize = strlen($salt);
$cipher->setIV($salt);
$cipher->setKey($key);
$decrypt = $cipher->decrypt($data);
echo($decrypt);
return $decrypt;
}
I am getting decrypt
message as null. I take a look into the lib and gone through some classes which named as "Base.php" and try to debug out when it actual decrypting data. I dump plaintext and got an output as below.
<pre class='xdebug-var-dump' dir='ltr'>
<small>G:\Installer\wamp64\www\userRegistration\lib\phpseclib\Crypt\Base.php:1081:</small>
<small>string</small>
<font color='#cc0000'>'Zx�Q���'m�ԉ��^�ܶB�eKs�>�`��_����c^��m������h�~Ut�'�'</font>
<i>(length=64)</i>
</pre>
can anyone help me in this? or is this way correct to do or any methodology i missed here?