方案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);
?>

一个好用的图片裁剪,水印类 intervention/image,支持gd库和image和imagick

安装 composer require intervention/image 使用文档:http://image.intervention.io/getting_started/introduction 类库 <?php /* * 图片处理 */ name...

阅读全文

php正则获取字符串中的图像src地址

<?php $str = <<<str <img src="1.jpg"/> <p>123123</p> <span>3322</span> <img ...

阅读全文

php predis 操作类库扩展

需先安装php predis 类库 详细predis 命令参考 :http://www.koukousky.com/back/1644.html <?php /** * Predis缓存驱动 * 要求安装phpredis扩展:https...

阅读全文

欢迎留言