ile! = null) {{ = new BufferedWriter (new FileWriter (msgFile)); (byte b: data) {. write (b);
}. close ();
} catch (IOException e1) {. out.println ("File not save");
}
}
}
}
});
} byte [] readDataFrom (File keyFile) {{bb = ByteBuffer.allocate ((int) keyFile.length ()); = new BufferedReader (new FileReader (keyFile)); (br.ready ()) {. put ((byte) br.read ());
}. close ();. array ();
} catch (IOException e) {new byte [0];
}
} void reloadImage (File imageFile) {image; = null; {= ImageIO.read (imageFile);. yield ();
} catch (IOException e1) {. out.println ("Load image error");
} (imageLabel, image); (true, closeBmpButton, writeTextArea, writeMessageButton, readMessageButton, readTextPane);
} (File imageFile) {{. isFullContainer (imageFile, key);
} catch (IOException e) {false;
}
} void setRightIconTo (JLabelimageLabel, BufferedImage image) {= getMinimumBound (image.getWidth (), image.getHeight (), imagePanel.getWidth (), imagePanel.getHeight ()); = (int) (image.getWidth () * minBoundCoefficient) - 7; = (int) (image.getHeight () * minBoundCoefficient) - 7; imageIcon = image.getScaledInstance (imageWidth, imageHeight, Image.SCALE_DEFAULT); icon = new ImageIcon (imageIcon) ;. setIcon (icon);
} double getMinimumBound (intinWidth, intinHeight, intoutWidth, intoutHeight) {. min ((double) outWidth/inWidth, (double) outHeight/inHeight);
} void setEnabledTo (boolean enabled, JComponent ... params) {(params.length == 0) {;
} (JComponentparam: params) {. setEnabled (enabled);
}
}
}
КлассStegoMessenger: class StegoMessenger {static final int BYTE_SIZE = 8; static final int MSG_LENGTH_PREFIX = 4 * 8; static final int BMP_HEADER_LENGTH = 54; static final int MSG_CHECK_PREFIX = 4 * 8; static final long [] CHECK_MESSAGE_NUMBER = {314159265l}; static final int GLOBAL_PREFIX = BMP_HEADER_LENGTH + MSG_CHECK_PREFIX + MSG_LENGTH_PREFIX; static final Random rand = new Random (); static long getMaximumMessageByteLength (File file) {(file.length () - GLOBAL_PREFIX)/8;
} static void writeToImage (File image, String message, String key) {= null; = BitSet.valueOf (key.getBytes ()); = BitSet.valueOf (message.getBytes ()); = (int) messageBitSet.length (); check; length; = BitSet.valueOf (CHECK_MESSAGE_NUMBER); = BitSet.valueOf (new long [] {(long) messageBitLength}); [] checkPixels; [] lengthPixels; [] messagePixels ; tail; {= new RandomAccessFile (image, "r...