Cesium 防止代码被抄袭、拷贝,这里推荐一个混淆方法,亲测有效

本文详细介绍了如何通过NodeJS和requireJS进行项目文件混淆,包括安装步骤、requireJS配置、bat脚本的使用以及混淆过程。从earth项目结构到实际操作,为requireJS开发者提供了一套完整的混淆指南。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

混淆步骤

项目文件结构

tool文件下

earth项目结构(requirejs项目)

1.安装nodeJS
2.下载一个requireJS ,这个是压缩文件
这个是用requirejs开发的r.js文件发布到earth-build下面,然后在发布的文件下面进行混淆
这一步在tool文件下有个bat文件,双击就可以了。

start.bat

node r.js -o build.js optimize=none

 

build.js 

{
    "appDir": "../earth",
    "baseUrl": "scripts",
    "dir": "../earth-build",
    //Comment out the optimize line if you want
    //the code minified by UglifyJS
    "optimize": "none",

    // point to the shim config we set up before
    "mainConfigFile": "../earth/scripts/app.js",    "modules": [
        //Optimize the application files. jQuery and the plugins will be included
        //automatically, as they are dependencies of app.js.
        {
            "name":"app"
        }
    ]
}

server.js

/*
 * node static file server:
 * modified from https://gist.github.com/rpflorence/701407
 */
/*jslint evil: true, nomen: true, sloppy: true */

var http = require('http'),
    url = require('url'),
    path = require('path'),
    fs = require('fs'),
    port = process.argv[2] || 8888,
    types = {
        'html': 'text/html',
        'js': 'application/javascript'
    },
    site = 'http://localhost:' + port;

http.createServer(function (request, response) {
    var uri = url.parse(request.url).pathname,
        filename = path.join(__dirname, '..', uri);

    fs.exists(filename, function (exists) {
      if (!exists) {
          response.writeHead(404, {'Content-Type': 'text/plain'});
          response.write('404 Not Found\n');
          response.end();
          return;
      }

      if(!fs.lstatSync(filename).isDirectory()) {
            var type = filename.split('.');
            type = type[type.length - 1];

            response.writeHead(200, { 'Content-Type': types[type] + '; charset=utf-8' });
            fs.createReadStream(filename).pipe(response);
      } else {
        /**
         * if users visit the site such as http://localhost:8888
         * then lead them to http://localhost:8888/www/app.html
         */
        response.writeHead(301, {'Location': site + '/www/app.html' });
        response.end();
     }
  });
}).listen(parseInt(port, 10));

console.log('Static file server running at\n  => ' + site + '/\nCTRL + C to shutdown');

 

index.html

3.npm install uglifyjs
4.然后就可以双击bat文件了。它是在当前文件下搜索js文件进行混淆。

——————————————————————————————————————

以上文章仅供学习参考,有任何侵权问题,请联系本人!原创文章默认开启打赏,任何钱财法律纠纷概不负责。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值