黑马程序员————————IO流(图片加密)

来源:互联网 发布:2016淘宝睡衣模特红人 编辑:程序博客网 时间:2024/05/19 00:09
public class Test1 {    /**     * 将写出的字节异或上一个数,这个数就是密钥,解密的时候再次异或就可以了     */    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();    }}
0 0
原创粉丝点击