PHP7.1 mcrypt alternative

call to undefined function mcrypt_encrypt
php7 4 mcrypt
encryption in php 7
php openssl_encrypt
mcrypt_encrypt enable
mcrypt vs libsodium
openssl_decrypt
openssl_encrypt codeigniter

Mcrypt function has been deprecated as of PHP 7.1.0.

My deprecated string encode / decode functions:

$key: secret key
$str: string


$encoded = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $str, MCRYPT_MODE_CBC, md5(md5($key))));

$decoded = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($str), MCRYPT_MODE_CBC, md5(md5($key))), "\0");

Can you suggest some alternatives?

You should use openssl_encrypt instead.

PHP7.1 mcrypt alternative, The url has changed: https://odan.github.io/2017/07/14/replace-mcrypt-encrypt-​with-openssl- srathbone commented over 1 year ago • edited over 1 year ago. Install Nginx, MariaDB and PHP 7.1 (LEMP) with Ubuntu 16.04 LTS Server Posted on 01/08/2018 04/04/2020 by Student Looking for an easy way to install and configure LEMP on Ubuntu 16.04 LTS?

Consider using defuse or RNCryptor, they provide a complete solution, are being maintained and is correct.

PHP7.1 mcrypt alternative, First addressing the mcrypt and php 7.2 issue and then the For 7.x-1.x version default option changed to use PHPSecLib. Drupal 7 doesn't support php 7. 2 in its 1. No problem, some times there is no option, but usually there is an alternative, although it's time more consuming to resolve the issue. As mentioned above, open_ssl is a good alternative for mcrypt. The only problem I had with open_ssl, is that it cannot be used for large strings. I wrote a script (static class), which overcomes this problem (large strings are split up in chunks and encrypted/decrypted separately in the background).

For MCRYPT_RIJNDAEL_256 I posted a full answer for PHP7.3 here: https://stackoverflow.com/a/53937314/243782

snippet:

works like this with the phpseclib library

$rijndael = new \phpseclib\Crypt\Rijndael(\phpseclib\Crypt\Rijndael::MODE_ECB);
$rijndael->setKey(ENCRYPT_KEY);
$rijndael->setKeyLength(256);
$rijndael->disablePadding();
$rijndael->setBlockLength(256);

$decoded = $rijndael->decrypt($term);

PHP7.1 mcrypt Alternative, 1. For MCRYPT_RIJNDAEL_256 I posted a full answer for PHP7.3 here: $​encryptedMessage); } mcrypt may be removed in PHP 7.1 alternative openssl. share. Update: On Debian 9 i must reinstall a lot of packages: apt-get install php-zip php-zeroc-ice php-xml php-tcpdf php-ssh2 php-soap php-snmp php-redis php-php-gettext php-mysql php-pear php-net-smtp php-net-socket php-net-imap php-net-nntp php-mcrypt php-mbstring php-imap php-intl php-json php-imagick php-gnupg php-gd php-geoip php-fpm php-dev php-mail php-mail-mime php-curl php-cli php-cgi php

echo encrypt_openssl($str, $key);

function encrypt_openssl($msg, $key, $iv = null) {
        $iv_size = openssl_cipher_iv_length('AES-256-CBC');
        if (!$iv) {
            $iv = openssl_random_pseudo_bytes($iv_size);
        }
        $encryptedMessage = openssl_encrypt($msg, 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv);
        return base64_encode($iv . $encryptedMessage);
    }

mcrypt may be removed in PHP 7.1 alternative openssl

Replace mcrypt_encrypt with openssl_encrypt · GitHub, (PHP 4 >= 4.0.2, PHP 5, PHP 7 < 7.2.0, PECL mcrypt >= 1.0.0). mcrypt_encrypt — Encrypts Example #1 mcrypt_encrypt() Example. <?php # --- ENCRYPTION  Mcrypt no se ha ido, solo se mudó. No te preocupes: mcrypt no se ha ido. Simplemente se ha movido fuera de PHP y dentro de PECL. Pero para aquellos que han estado instalando a través de php-mcrypt durante años, esto representa un gran cambio. Ahora, en lugar de poder instalar mcrypt con un solo comando, tienes que lidiar con cuatro.

As mentioned above, open_ssl is a good alternative for mcrypt. The only problem I had with open_ssl, is that it cannot be used for large strings.

I wrote a script (static class), which overcomes this problem (large strings are split up in chunks and encrypted/decrypted separately in the background).

See public gist: https://gist.github.com/petermuller71/33616d55174d9725fc00a663d30194ba

What to do with "mcrypt" message after upgrading to PHP 7.2 , (PHP 4 >= 4.0.2, PHP 5, PHP 7 < 7.2.0, PECL mcrypt >= 1.0.0) chaining mode or no IV was provided, but the chaining mode requires one, the function will emit​  The mcrypt extension is an interface to the mcrypt cryptography library. This extension is useful for allowing PHP code using mcrypt to run on PHP 7.2+. The main problem with mcrypt extension is that it is based on libmcrypt that hasn’t been developped since its upstream in 2007. Thus, it has been already 10 years, even though the library has

mcrypt_encrypt - Manual, Install mcrypt PHP module Now we are ready to install mcrypt PHP module on our Ubuntu 18.04 system: $ sudo pecl channel-update pecl.php.net $ sudo pecl install mcrypt-1.0.1

mcrypt_decrypt - Manual, mcrypt_on_php7.3_.txt # The php-mcrypt extension is depricated and therefore was removed from the apt repository. # As of writing this, on php7.3 there is currently no other way to install mcrypt without downgrading the php version

“apt-get install php7.0-intl php7.0-mcrypt php-imagick php7.0-xml php7.0-zip” I guess something newer must be in the pipeline . . . TBH I think rather do PHP7.1, but use that manual as reference. I think they use 7.0 install as the reference for all to use. I cannot speak for them, but I have install NC14 with PHP7.2 on CentOS without any

Comments
  • You're out out of luck here. You're using a Rijndael-256 cipher, which is very unusual and not supported by OpenSSL. What you probably meant is AES-256, which is Rijndael-128 with a 256 bit key. If switching ciphers is an option for you, switch to Rijndael-128, in which case you can use OpenSSL.
  • why not just use sha-256 (sha version 2)
  • Possible duplicate of mcrypt is deprecated, what is the alternative?
  • Encrypt example: micmap.org/php-by-example/en/function/openssl_encrypt , Decrypt example: micmap.org/php-by-example/en/function/openssl_decrypt