方案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 $mail = new \App\Common\Lib\Mail\AliMail(); list($res, $error) = $mail->setSubject(...

阅读全文

php 向函数传引用

当你要传递的值特别大时,使用传引用的方式 会减小内存的开销。或者当你需要改变传递参数的原值时,也可以使用此方式。 <?php /** * 测试 */ class Tes...

阅读全文

elasticsearch+kibana+filebeat+headPlugin配置参考

参考链接 filebat: https://www.elastic.co/cn/downloads/beats/filebeat https://www.elastic.co/cn/products/beats/filebeat Elastic Stack : https://www...

阅读全文

欢迎留言