- 运行界面
- 代码分析:
调用check方法,传入参数是获取用户是输入,抛出异常就“错误”
public void onClick(View arg5) {
DialogInterface$OnClickListener v3 = null;
try {
this.b.check(this.a.getText().toString());
new AlertDialog$Builder(this.b).setMessage("正确").setNeutralButton("OK", null).create().show();
}
catch(Exception v0) {
new AlertDialog$Builder(this.b).setMessage("错误").setNeutralButton("OK", v3).create().show();
}
}
check方法实现加密逻辑
public void check(String arg10) {
String v0_1;
int v7 = 15;
int v6 = 7;
int v1 = 0;
int v5 = 5;
if(arg10.length() != 16) { //长度不等于16抛出异常,说明key的长度等于16
throw new RuntimeException();
}
try {
v0_1 = this.getKey(); // "bobdylan"
}
catch(Exception v0) {
v0_1 = this.getKey();
System.arraycopy(v0_1, 0, arg10, v5, v5);
}
int[] v2 = new int[16]; //创建一个16位的数组与我们要的key的长度一致
v2[0] = 0; //v2[0] = 0
v2[12] = 14; //v2[12] = 14
v2[10] = v6; //v2[10] = 7
v2[14] = v7; //v2[14] = 15
v2[v7] = 42; //v2[15] = 42
int v4 = 3;
try {
v2[1] = v4; //v2[1] = 3
v2[5] = 5; //v2[5] = 5
System.out.println();
}
catch(Exception v3) {
v2[v5] = 37;
v2[1] = 85;
}
v2[6] = v7; //v2[6] = 15
v2[2] = 13; //v2[2] = 13
v2[3] = 19; //v2[3] = 19
v2[11] = 68; //v2[11] = 68
v2[4] = 85; //v2[4] = 85
v2[13] = v5; //v2[13] = 5
v2[9] = v6; //v2[9] = 7
v2[v6] = 78; //v2[7] = 78
v2[8] = 22; //v2[8] = 22
//得到v2[]={0,3,13,19,85,5,15,78,22,7,7,68,14,5,15,42};
while(v1 < arg10.length()) {
if((v2[v1] & 0xFF) != ((arg10.charAt(v1) ^ v0_1.charAt(v1 % v0_1.length())) & 0xFF)) { //用key的值与"bobdylan"进行异或然后和v2进行比较,那么用v2和"bobdylan"异或就能得到key了
throw new RuntimeException();
}
++v1;
}
}
- 解题思路
编写解密代码得到 key
public static void main(String[] args) {
int v2[]={0,3,13,19,85,5,15,78,22,7,7,68,14,5,15,42};
String b="bobdylan";
int v1=0;
while(v1 < 16) {
System.out.print((char) ((v2[v1] & 0xFF) ^ (b.charAt(v1 % 8) & 0xFF)));
++v1;
}
}
运行结果:blow,in the winD