0

i try change my code for now use openssl_encrypt because mcrypt_* is deprecated on PHP 7.1 and removed for PHP 7.2.

Here my present code with mcrypt and MCRYPT_RIJNDAEL_256:

<?php
class Encoder {

    protected $_saltA; // 32 chars
    protected $_saltB; // 32 chars

    public function __construct($data = null){
        $this->_saltA = _GLOBAL_ENCRYPT_SALTA;
        $this->_saltB = _GLOBAL_ENCRYPT_SALTB;
    }

    public function passwordEncode($value){
        if(!$value || $value == ""){
            return "";
        }else{
            $rtn = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->_saltA, $value, MCRYPT_MODE_CBC, $this->_saltB);
            return base64_encode($rtn);
        }
    }

    public function passwordDecode($value){
        if(!$value || $value == ""){
            return "";
        }else{
            $value = base64_decode($value);
            $rtn = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this->_saltA, $value, MCRYPT_MODE_CBC, $this->_saltB);
            return rtrim($rtn, "\0\4");
        }
    }

}

Thank you for help

4
  • 2
    I could have SWORN you said I am try change my code for now use openssl_encrypt But I dont see that you have tried at all. In fact it looks like you are asking us to Do It For You Commented Apr 24, 2017 at 14:34
  • stackoverflow.com/questions/41272257/… being a possible duplicate; what do you think @RiggsFolly Edit: and/or stackoverflow.com/questions/41740600/php7-1-mcrypt-alternative Commented Apr 24, 2017 at 14:38
  • 1
    Works for me @Fred-ii- Commented Apr 24, 2017 at 14:39
  • 1
    @RiggsFolly Gotta love code barf Commented Apr 24, 2017 at 14:42

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.