java字节流加密图片,具体操作是单个字节异或一个数字,为什么加密后的图片无法打开
FileInputStream fis = null; FileOutputStream fos = null; try { fis = new FileInputStream("haha.jpg"); fos = new FileOutputStream("hahasecret.jpg"); byte[] buffer = new byte[20]; int len; while ((len = fis.read(buffer)) != -1) { for (int i = 0; i < len; i++) { buffer[i] = (byte) (buffer[i] ^ 1); } fos.write(buffer, 0, len); } } catch (IOException e) { e.printStackTrace(); } finally { if (fos != null) { try { fos.close(); } catch (IOException e) { e.printStackTrace(); } } if (fis != null) { try { fis.close(); } catch (IOException e) { e.printStackTrace(); } } }
不应该是可以打开但是里面的内容是乱的吗
Sign in to make a reply
_圣女果
java字节流加密图片,具体操作是单个字节异或一个数字,为什么加密后的图片无法打开
不应该是可以打开但是里面的内容是乱的吗