php-openssl
Use openssl_encrypt to replace Mcrypt for 3DES-ECB encryption
now I want to encrypt it use openssl_encrypt, and I did not find des3-ecb in openssl_get_cipher_methods() list. It’s des-ede3. Symmetric encryption with a block cipher needs some kind of mode of operation. If you look through the list, you will see something like des-ede3, des-ede3-cbc, des-ede3-cfb and des-ede3-ofb. CBC, CFB and OFB are all named … Read more
How to enable PHP’s openssl extension to install Composer?
It is possible that WAMP and Composer are using different PHP installations. Composer will use the PHP set in the PATH environment variable. If you want to enable the openssl extension to install Composer, first you need to check the location of the PHP installation. Open a Command Prompt, type: echo %PATH% then check for … Read more
Can’t decrypt using pgcrypto from AES-256-CBC but AES-128-CBC is OK
MCRYPT_RIJNDAEL_256 isn’t AES-256. It’s the Rijndael cipher with a block size of 256 (hence the error). AES is a subset of the Rijndael cipher using block size of 128 bits and key sizes of 128, 192 and 256 bits. This is also reflected in the IV size. To create an AES-256 encrypted ciphertext you can … 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
mcrypt_encrypt to openssl_encrypt, and OPENSSL_ZERO_PADDING problems
mcrypt_encrypt zero-pads input data if it’s not a multiple of the blocksize. This leads to ambiguous results if the data itself has trailing zeroes. Apparently OpenSSL doesn’t allow you to use zero padding in this case, which explains the false return value. You can circumvent this by adding the padding manually. $message = “Lorem ipsum”; … Read more