这里会对服务器下发数据进行解密:
try{
Map b=i.b(a.b(a.b(new String(bArr,"utf-8")));
Log.d("MainActivity","get config ok:"+b);
看看解密算法实现:
public static String b(String str) throws Exception{
String str2=null;
String str3="iYE3uk4J6N6T4Aq4";
try{
if(str3.length()!=16){
System.out.print("Key长度不是16位");
}else{
Key secretKeySpec=new SecretKeySpec(str3.getBytes("ASCII"),"AES");
Clipher instance=Cipher.getInstance("AES/CBC/NoPadding");
instance.init(2,secretKeySpec,new IvparameterSpec("0000000000000000".getBytes()));
byte[] bytes=str.getBytes(AsyncHttpResponseHandler.DEFAULT_CHARSET);
try{
...
}catch(){
...
}
}
}catch(){
...
}
return str2;
}
注意:Cipher类提供加密和解密功能
一个很简单的AES算法。key也是本地写死的。我们为了后面验证解密算法有效。我们在单独写一个Android程序,把这部分解密函数拷贝出去,然后用来解密数据:
…
然后我们用刚刚打印的日志中的获取配置url,放到浏览器中访问查看
解密之后是一个json数据,我们用工具进行格式化查看信息: