class Test{
public static void main(String[] args) throws Exception{
File file = new File("1.jpg");
FileInputStream in = new FileInputStream(file);
FileOutputStream out = new FileOutputStream("2.jpg");
byte[] b = new byte[1024];
int ch;
while((ch = in.read(b))!=-1){
for(int i = 0 ;i < ch ;i++){
if(b[i]==28){
b[i]=30;
}
else if(b[i] == 30){
b[i] = 28;
}
}
out.write(b);
}
in.close();
out.close();
}
}
再下面的是解密过程
import java.io.*;
class Break{
public static void main(String[] args) throws Exception{
File file = new File("2.jpg");
FileInputStream in = new FileInputStream(file);
FileOutputStream out = new FileOutputStream("3.jpg");
byte[] b = new byte[1024];
while(in.read(b)!=-1){
for(int i =0;i<b.length;i++){
if(b[i]==28){
b[i]=30;
}
else if(b[i]==30){
b[i] = 28;
}
}
out.write(b);
}
in.close();
out.close();
}
}