Android软件加安全码


package Decode;

import java.util.Base64;
import java.io.InputStream;
import java.io.ByteArrayInputStream;
import java.io.ObjectInputStream;
import java.io.OptionalDataException;
import java.io.StreamCorruptedException;
import java.util.Arrays;

public class DecodeObject{
	public static void main(String args[]) throws Exception{
		int skip=0;
		int remainder = 0;
		String b64 = args[0];
		byte[] bytes = Base64.getDecoder().decode(b64);
		ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
		int origSize = bis.available();
		System.out.println("Data Length: "+origSize);
		Object o = null;
		while(o == null){
			try{
				bis.reset();
				bis.skip(skip);
				ObjectInputStream ois = new ObjectInputStream(bis);
				o = ois.readObject();
				
				System.out.println("Object found...");
				System.out.println(o.getClass().getName());
				System.out.println("Bytes skipped: "+skip);
				System.out.println("Bytes left: "+bis.available());
				skip = origSize - bis.available();
			}
			catch (StreamCorruptedException ode){
				skip = skip+1;
				bis.skip(1);
			}
			catch (OptionalDataException ode){
				bis.skip(1);
				skip = skip+1;
			}
			catch (ClassNotFoundException cnf)
			{
				System.out.println("Object found..."+cnf.getMessage());
				System.out.println("Bytes skipped: "+skip);
				System.out.println("Bytes left: "+bis.available());
				skip = origSize - bis.available();
			}
		}
	}
}


优质内容筛选与推荐>>
1、Swift - 设置程序的应用图标和启动界面
2、奥巴马给女儿的信:我们可以不断让它变得更好
3、Struts学习笔记_i18n
4、胜利大逃亡(续)
5、郭树清当选中国建设银行股份有限公司董事长


长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号