package com.fenqing.Stream;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class test_picture {
/**
* 此处只以图片加密为例
*/
public static void main(String[] args) throws IOException {
BufferedInputStream bis=new BufferedInputStream(new FileInputStream("ali.jpg"));
BufferedOutputStream bos=new BufferedOutputStream(new FileOutputStream("alicopy.jpg"));
int b;
while((b=bis.read())!=-1){
bos.write(b^123); //将写出的字节异或一个数,即加密
} //再异或同一个数字,即解密
bis.close();
bos.close();
}
}
IO流(8)--对数据进行加密
最新推荐文章于 2024-05-21 23:50:10 发布