This is my code :
function decrypt($code)
{
$key = '3552ef55ecdf04324..'; // 64 bytes length
$iv = 'd20818af907b59c3b15d258dd3969770'; // 32 bytes length
$key = hash("sha256", $key,true); // 32 bytes length
$iv = md5($iv,true); // 16 bytes length
echo strlen(base64_decode($code)); // 80 bytes
//return openssl_decrypt(base64_decode($code), 'aes-256-cbc', $key, 0 ,$iv); // return false
$output = openssl_decrypt(base64_decode($code), 'aes-256-cbc', $key, 0 ,$iv);
return openssl_error_string();
}
I encrypt using swift/android and i decrypt using php.
The openssl_error_string() method return "error:0606506D:digital envelope routines:EVP_DecryptFinal_ex:wrong final block length".
Note that the key and iv in encryption swift/android are the same. I cant find the problem here. Anyone? Thanks.
base64_decode($code)), it may not be what you think it is.. R-; 0040 f6 a1 46 5a ec 54 55 54 04 8f 00 60 09 cf af c2 FZTUT ...</pre> @zaph$codein the comment is not valid Base64 encoding based on its length, 109 characters, there is an invisible character in it. The plain text is 64 characters and would be padded with 16 0x10 bytes so that would make 80 bytes.