方案1

直接输入 pecl install mcrypt-snapshot
此方案的好处是不用改代码

方案2

<?php
class Encrypt{

    //base64_encode(openssl_random_pseudo_bytes(32));
    public $key    = "qK37s8Sb0uTDflFsHVwfWqZpySDXo6uHJVMGC3UOJsU=";
    //echo base64_encode(openssl_random_pseudo_bytes(16));
    public $iv    = "EXWPKlAyhkCjqMQkxkkyyA==";

    public function encrypt($value){

        $encrypted = openssl_encrypt($value, 'aes-256-cbc', base64_decode($this->key), OPENSSL_RAW_DATA, base64_decode($this->iv));
        return base64_encode($encrypted);
    }

    public function decrypt($string){
        $encrypted = base64_decode($string);
        $decrypted = openssl_decrypt($encrypted, 'aes-256-cbc', base64_decode($this->key), OPENSSL_RAW_DATA, base64_decode($this->iv));
        return $decrypted;
    }
}

//测试
$encrypt = new Encrypt();

$arr = [
    'a'   =>   '1',
    'b'   =>   '2'
];
$des = $encrypt->encrypt(json_encode($arr));
echo $encrypt->decrypt($des);
?>

php 二维数组根据某个键值倒叙、升序排序

<?php $array = [ [ 'title' => '标题5', 'views' => 500 ], [ 'title&...

阅读全文

一个好用的php id加密解密类,适用于隐藏用户真实id。hashids

效果 <?php use Hashids\Hashids; $hashids = new Hashids(); // no padding $hashids->encode(1); #结果 jR #指定返回10个字符长度的加密串 $hashids...

阅读全文

yum 安装redis5

更新yum源 # EPEL的全称叫 Extra Packages for Enterprise Linux 。EPEL是由 Fedora 社区打造,为 RHEL 及衍生发行版如 CentOS、Scientific Linux 等提供高质...

阅读全文

欢迎留言