openssl_encrypt decrypt实现加密解密

/**
     * 使用openssl_encrypt加密
     * $data = '1234567887654321';//加密明文
     * $method = 'DES-ECB';//加密方法
     * $passwd = '12344321';//加密密钥
     * $options = 0;//数据格式选项(可选)
     * $iv = '';//加密初始化向量(可选)
     * 
     */

    public static function encrypt($data, $method = 'DES-ECB', $passwd = '12344321', $options = 0, $iv = '')
    {
        return openssl_encrypt($data, $method, $passwd, $options);
    }

    /**
     * 使用openssl_decrypt解密
     * 
     */
    public static function decrypt($data, $method = 'DES-ECB', $passwd = '12344321', $options = 0, $iv = '')
    {
        return openssl_decrypt($data, $method, $passwd, $options);
    }

 

你可能感兴趣的:(laravel框架)