Eption and decryption are fundamental requirements of every secure-aware application, therefore the PHP provides strong support for encryption and decryption through its  cryptographic algorithms such as AES, DES, DESede and RSA in SHA256, MD5, ISO encryption. Recently its need to me encrypt a data and I have used this code as its .


skey, $text, MCRYPT_MODE_ECB, $iv);
        return trim($this->safe_b64encode($crypttext)); 
    }
    
    public function decode($value){
        
        if(!$value){return false;}
        $crypttext = $this->safe_b64decode($value); 
        $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
        $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
        $decrypttext = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this->skey, $crypttext, MCRYPT_MODE_ECB, $iv);
        return trim($decrypttext);
    }
}

//uses
$data = array('abc'=>123, 'bn'=>12); 
//use data, NB: use string to send by get/post method
$c = new Encryption();
echo $encData = $c->encode($data);

$c = new Encryption();
echo $c->decode($encData );