<?php
/*
 *  加密解密类
 */

namespace app\common\lib\encrypt;

use Defuse\Crypto\Key;
use Defuse\Crypto\Crypto;

#使用之前需先安装 defuse/php-encryption

class CryptoKey {

    public static $key = 'def00000c489c83f378af872f8b156896bdc50c3441305b795f54c4150b21d9742e5695568a03b64c968bbfbaed295ce7e661df53232e31a2c9169d39f759a1fa1260541';

    public static function loadEncryptionKeyFromConfig() {
//        $keyAscii = '';// ... load the contents of /etc/daveapp-secret-key.txt
        return Key::loadFromAsciiSafeString(self::$key);
    }

    //加密
    public static function encrypt($str = '') {
        return Crypto::encrypt($str,self::loadEncryptionKeyFromConfig());
    }
    //解密
    public static function decrypt($str = '') {
        return Crypto::decrypt($str,self::loadEncryptionKeyFromConfig());
    }
    #生成key
    public static function createKey() {
        $key = Key::createNewRandomKey();
        echo $key->saveToAsciiSafeString(), "\n";
    }
}

nginx 解析php conf配置文件

本博客的nginx 配置文件 server { listen 80;#80和443端口同时监听 listen 443 ssl; server_name www.koukousky.com koukousky.com...

阅读全文

php composer 安装阿里云镜像

#doc: https://developer.aliyun.com/composer 全局配置(推荐) composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ 取消配...

阅读全文

intervention/image处理IOS上传图片翻转问题

#安装 $ composer require intervention/image <?php use Intervention\Image\ImageManagerStatic as Image; //test.png要处理的图片路径 Image::make(&...

阅读全文

欢迎留言