1、简单加密
package com.asiainfo.group.file_encrypt;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;

public class FileEncrypt {
	public static final int KEY = 123;
	public static final String PATH = "E:/test/";
	public static final String FILENAME = "山河.jpg";
	public static final String FILENAME_ENCRYPT = "山河_en.jpg";
	
	public static void encrypt() throws Exception{
		InputStream in = new FileInputStream(PATH+FILENAME);
		OutputStream out = new FileOutputStream(PATH+FILENAME_ENCRYPT);
		
		
		
		int data = 0;
		
		while((data=in.read())!=-1){
			out.write(data^KEY);
		}
		out.flush();
		out.close();
		in.close();
	}
	
	public static void decrypt() throws Exception{
		InputStream in = new FileInputStream(PATH+FILENAME_ENCRYPT);
		OutputStream out = new FileOutputStream(PATH+FILENAME);
				
		int data = 0;
		
		while((data=in.read())!=-1){
			out.write(data^KEY);
		}
		out.flush();
		out.close();
		in.close();
	}
	
	
	
	
	public static void main(String[] args) throws Exception {
		
		decrypt();
		

	}

}