一个工具类,生成一些废代码,用于混淆

Posted gamedaybyday

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了一个工具类,生成一些废代码,用于混淆相关的知识,希望对你有一定的参考价值。

 

发布多个微信小游戏,因为用的游戏框架是同一个,被微信判定代码雷同不给过审核。

于是加了点废代码。不知道能不能过哦。如果是人工审核,那基本没戏。。。 

 

 

工具类

/**
 * 生成一些废代码,用于混淆
 * @author chenkai 2018/10/7
 */
class ConfuseTool {
	public constructor() {


	}

	public static createClass(num:number){
		let str = "";
		for(let i=0;i<num;i++){
			//类
			str += "class " + this.getLetter() + "{" + "
";

			//属性
			for(let i=0;i<20;i++){
				str += "    public " + this.getLetter() + ";"+ "
";
			}

			//函数
			for(let i=0;i<20;i++){
				str += "    public " + this.getLetter() + "(){"+ "
";
				for(let i=0;i<10;i++){
					str += "        let " + this.getLetter() + " = ‘" + this.getLetter() + "‘;"+ "
";
				}
				str += "    }"+ "
";
			}
			//类结束
			str += "}"+ "
";
		}
		return str;
	}




	/**混淆的字母和数字 */
	public static confuseStr = "abcdefghijklmnopqrstuvwxyz";
	/**获取混淆的字符串 */
	public static getLetter(){
		let str = "";
		let strLen = this.confuseStr.length;
		let len = 20;
		for(let i=0;i<len;i++){
			str += this.confuseStr.charAt(Math.round(Math.random()*(strLen-1)));
		}
		return str;
	}

}

  

使用

console.log(ConfuseTool.createClass(1));

  

浏览器打印

技术分享图片

 

以上是关于一个工具类,生成一些废代码,用于混淆的主要内容,如果未能解决你的问题,请参考以下文章

代码编译-反编译-解混淆

allatori代码混淆工具能与maven结合吗

创建自己的代码片段(CodeSnippet)

Android Studio 生成混淆后的jar包

谁给推荐个c++代码混淆工具

前端开发工具vscode如何快速生成代码片段