將寫出的字異或上一個數,這個數就是密碼,解密的時候再次異或就可以了
public static void main(String [] args){
BufferedInputStream bis = new BufferedInputStream(new FileInputStream("紫薇.jpg"));
BufferedOutputStream bos = new BufferedOutputStream (new FileOutputStream("加密后的紫薇.jpg"));
int b;
while((b = bis.read()) != -1){
bos.write(b ^ 123); //给图片加密
}
bis.close();
bos.close();
}
public static void main(String [] args){
BufferedInputStream bis = new BufferedInputStream(new FileInputStream("加密后的紫薇.jpg"));
BufferedOutputStream bos = new BufferedOutputStream (new FileOutputStream("解密后的紫薇.jpg"));
int b;
while((b = bis.read()) != -1){
bos.write(b ^ 123); //给图片解密
}
bis.close();
bos.close();
}