简单的对图片进行加密与解密
//图片加密
public static void encryptionPicture() throws IOException {
FileInputStream fis = new FileInputStream("C:\\Users\\xxx\\Desktop\\exercise\\IMG_3501.JPG");
FileOutputStream fos = new FileOutputStream("C:\\Users\\xxx\\Desktop\\exercise\\IMG_3500.JPG");
int s;
while((s=fis.read()) != -1) {
fos.write(s^123);
}
fis.close();
fos.close();
}
对图像的解密就是将你加密的规则进行重新运算一遍
//图片解密
public static void decryptPicture() throws IOException {
FileInputStream fis = new FileInputStream("C:\\Users\\xxx\\Desktop\\exercise\\IMG_3500.JPG");
FileOutputStream fos = new FileOutputStream("C:\\Users\\xxx\\Desktop\\exercise\\IMG_3503.JPG");
int s;
while((s=fis.read()) != -1) {
fos.write(s^123);
}
fis.close();
fos.close();
}