黑马程序员技术交流社区

标题: 图片加密 [打印本页]

作者: wanggan123    时间: 2016-5-22 00:12
标题: 图片加密
package study.test;
 
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
 
public class Test1 {
 
        /**
         * @param args
         * @throws IOException
         * 将写出的字节异或上一个数,这个数就是密钥,解密的时候再次异或就行了
         */
        public static void main(String[] args) throws IOException {
                BufferedInputStream bis = new BufferedInputStream(new FileInputStream("copy.jpg"));
                BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("copy2.jpg"));
               
                int b;
                while((b = bis.read()) != -1) {
                        bos.write(b ^ 123);
                }
               
                bis.close();
                bos.close();
        }
 
}
作者: hycold    时间: 2016-5-22 00:16
路过学习
作者: 守徒徒    时间: 2016-5-22 01:55
学习了!哈哈
作者: 王子鹏    时间: 2016-5-22 17:12
路过 学习了
作者: 2011014170    时间: 2016-5-22 19:07
学习了   。。。。。。。。。。。




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2