java不被反编译,防止JAVA代码被反编译的方法

本文介绍了一种高级的代码混淆技术,通过定义AntiCrack类和Fake函数,使得在IoException等异常处理中,即使反编译后的代码出现异常,也能确保程序流程的中断。Decafe、FrontEnd和YingJAD等工具在尝试反编译时遇到问题,推荐使用第二方法来增强代码安全性。
摘要由CSDN通过智能技术生成

方案二。

如果以上方法还不够专业,我们再来一个。呵呵~

1,同样的,我们定义一个类,这个类叫做AntiCrack.。名字好像有点大。。。代码如下:

public class AntiCrack

{

private AntiCrack()

{

}

public static Throwable Fake(Throwable throwable, Throwable throwable1)

{

try

{

throwable.getClass().getMethod("initCause", new Class[] {

JAVA手机网[www.cnjm.net]               java.lang.Throwable.class

}).invoke(throwable, new Object[] {

throwable1

});

}

catch(Exception exception) { }

return throwable;

}

}

2,同样的,我们在catch里面调用该函数。例如如下。

try

{

//your code here

}

catch(IOException ioexception)

{

IllegalArgumentException illegalargumentexception = new IllegalArgumentException(ioexception.toString());

AntiCrack.fake(illegalargumentexception, ioexception);

throw illegalargumentexception;

}

或者也可以这样

public class AntiException extends Exception

{

public AntiException()

{

}

public AntiException(String s)

{

super(s);

}

public AntiException(String s, Throwable throwable)

{

super(s);

AntiCrack.fake(this, throwable);

}

}

JAVA手机网[www.cnjm.net]然后在你的程序里面

try

{

}

catch(IoException e)

{

throw new AntiException(ioexception.toString(), ioexception);

}

当采用以上方式后,任何类只要调用了该函数,生成的class反编译后出错,得不到结果。

Decafe、FrontEnd和YingJAD,反编译时都有exception,然后无法进行下去。大家可以多测试变得反编译工具。建议推荐用第二个方法。

呵呵,有什么问题可以给我mail

来源:考试大-Java认证

责编:xxm  评论 纠错

2下一页

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值