Mcrypt js encryption value is different than that produced by PHP mcrypt / Mcrypt JS decrypt doesn’t work for UTF-8 chars

The main issue appears to be that your string_encrypt and string_decrypt PHP functions don’t have access to the $key variable, so for the encryption key mcrypt_encrypt is using \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0. See this question for an explanation. PHP should report a notice that key is undefined, have you turned off error reporting perhaps? Echo the key from … Read more

How to do AES256 decryption in PHP?

I’m not terribly familiar with this stuff, but it seems like trying MCRYPT_RIJNDAEL_256 in place of MCRYPT_RIJNDAEL_128 would be an obvious next step… Edit: You’re right — this isn’t what you need. MCRYPT_RIJNDAEL_128 is in fact the right choice. According to the link you provided, your key and IV are twice as long as they … Read more

Issue in installing php7.2-mcrypt

I followed below steps to install mcrypt for PHP7.2 using PECL. Install PECL apt-get install php-pecl Before installing MCRYPT you must install libmcrypt apt-get install libmcrypt-dev libreadline-dev Install MCRYPT 1.0.1 using PECL pecl install mcrypt-1.0.1 After the successful installation You should add “extension=mcrypt.so” to php.ini Please comment below if you need any assistance. 🙂 IMPORTANT … Read more

MCrypt rijndael-128 to OpenSSL aes-128-ecb conversion

Here is what worked for me: <?php $str=”Content”; if (strlen($str) % 16) { $str = str_pad($str, strlen($str) + 16 – strlen($str) % 16, “\0”); } $key = ‘KEY’; if (strlen($key) % 16) { $key = str_pad($key, strlen($key) + 16 – strlen($key) % 16, “\0”); } $res1 = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $str, MCRYPT_MODE_ECB); echo strToHex($res1) . ‘ … Read more