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

  • 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** – RiggsFolly Apr 24 '17 at 14:34
  • http://stackoverflow.com/questions/41272257/php-7-mcrypt-deprecated-need-alternative being a possible duplicate; what do you think @RiggsFolly Edit: and/or http://stackoverflow.com/questions/41740600/php7-1-mcrypt-alternative – Funk Forty Niner Apr 24 '17 at 14:38
  • 1
    Works for me @Fred-ii- – RiggsFolly Apr 24 '17 at 14:39
  • 1
    @RiggsFolly Gotta love code barf – Machavity Apr 24 '17 at 14:42

0 Answers0