tholu/php-packer

由 Dean Edwards 创建的 JavaScript 混淆库 Packer 的 PHP 版本

0.2.0 2016-04-19 10:33 UTC

This package is not auto-updated.

Last update: 2024-09-12 02:30:03 UTC


README

由 Nicolas Martin 将 Dean Edwards 创建的 JavaScript 混淆库 Packer 转移到 PHP 版本,由 Thomas Lutz 进行打包和稍作扩展,适用于 composer。

安装

只需运行 composer require tholu/php-packer

使用方法(与之前使用的实现略有不同!)

<?php
require 'vendor/autoload.php';

$js = file_get_contents('test.js');

/*
 * params of the constructor :
 * $script:           the JavaScript to pack, string.
 * $encoding:         level of encoding, int or string :
 *                    0,10,62,95 or 'None', 'Numeric', 'Normal', 'High ASCII'.
 *                    default: 62 ('Normal').
 * $fastDecode:       include the fast decoder in the packed result, boolean.
 *                    default: true.
 * $specialChars:     if you have flagged your private and local variables
 *                    in the script, boolean.
 *                    default: false.
 * $removeSemicolons: whether to remove semicolons from the source script.
 *                    default: true.
 */

// $packer = new Tholu\Packer\Packer($script, $encoding, $fastDecode, $specialChars, $removeSemicolons);
$packer = new Tholu\Packer\Packer($js, 'Normal', true, false, true);
$packed_js = $packer->pack();
echo $packed_js;

UTF8

如果你在 JavaScript 中有 UTF8 字符,如 这里 所示,请避免使用 "高 ASCII" 编码,而使用 "常规" 编码。同时,请确保文件以正确的 UTF8 编码保存和读取。