首页 > 编程语言 > 详细

java实现的加密解密

时间:2016-04-11 11:45:07      阅读:147      评论:0      收藏:0      [点我收藏+]
void encode(File enfile, File defile) throws Exception {
		String Algorithm = "DES";
		byte[] key = "cnmmlgb!".getBytes();
		SecretKey deskey = new SecretKeySpec(key, Algorithm);
		Cipher c = Cipher.getInstance(Algorithm);
		//c.init(Cipher.ENCRYPT_MODE, deskey);//加密模式
		c.init(Cipher.DECRYPT_MODE, deskey);//解密模式
		byte[] buffer = new byte[100 * 1024];
		FileInputStream in = new FileInputStream(enfile);
		OutputStream out = new FileOutputStream(defile);
		CipherInputStream cin = new CipherInputStream(in, c);
		int i;
		while ((i = cin.read(buffer)) != -1) {
			out.write(buffer, 0, i);
		}
		out.close();
		cin.close();
	}

 

java实现的加密解密

原文:http://www.cnblogs.com/wbjgogogo/p/5377636.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!