0

With PHP 7 my website does not work anymore correctly. I tried the recommendation on the website: https://gist.github.com/odan/c1dc2798ef9cedb9fedd09cdfe6e8e76, but it still does not work. Can anyone help me?

error message:

Fatal error: Uncaught Error: Call to undefined function mcrypt_encrypt() in /is/htdocs/wp12891720_A49KPJUSEX/www/chat.php:115 Stack trace: #0 /is/htdocs/wp12891720_A49KPJUSEX/www/chat.php(131): Crypt::encode('5c46ea88788a0aa...', Array) #1 {main} thrown in /is/htdocs/wp12891720_A49KPJUSEX/www/chat.php on line 115

class Crypt {
    static public function encode($key, $password) {
        $key .= date('Y-m-d H');
        return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), json_encode($password), MCRYPT_MODE_CBC, md5(md5($key))));
    }
}
Dharman
  • 30,962
  • 25
  • 85
  • 135
  • What exactly is this monstrosity supposed to do? Please do not tell me this is a part of some kind of authentication system. – Dharman Jan 21 '19 at 20:31
  • 1
    `open_ssl` is typically what you want to use, you can also use PHPSecLib which is a pretty nice library. – ArtisticPhoenix Jan 21 '19 at 20:36
  • 1. Passwords need to be _hashed_, not encrypted. 2. Why are you appending the current hour to the key? 3. Why are you `json_encode()`ing the password? 4. IVs should be random, not derived. Last, but not least, mcrypt's Rjindael cipher isn't compatible with any other library, you need to re-encode everything. Take the opportunity to hash your passwords instead. https://secure.php.net/manual/en/function.password-hash.php – Sammitch Jan 21 '19 at 20:49
  • 1
    That code gave me nightmares... – Luke Joshua Park Jan 21 '19 at 22:03
  • Possible duplicate of [php 7 Mcrypt PHP extension required](https://stackoverflow.com/questions/36402000/php-7-mcrypt-php-extension-required) – miken32 Jan 21 '19 at 22:15

1 Answers1

0

Because, This function has been DEPRECATED as of PHP 7.1.0. Check on official website PHP: mcrypt_encrypt - Manual. In my openion you can replace this with openssl_encrypt method