11.07.2015 Views

Java Art Chapter 6. Steganography

Java Art Chapter 6. Steganography

Java Art Chapter 6. Steganography

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Java</strong> Prog. Techniques for Games. <strong>Java</strong> <strong>Art</strong> <strong>Chapter</strong> <strong>6.</strong> Stego Draft #1 (7th June 09){the resulting image is stored in Msg.png */// read in the message as a byte arraybyte[] msgBytes = readMsgBytes(textFnm);if (msgBytes == null)return false;// generate a passwordString password = genPassword();byte[] passBytes = password.getBytes();// use password to encrypt the messagebyte[] encryptedMsgBytes = encryptMsgBytes(msgBytes, password);if (encryptedMsgBytes == null)return false;byte[] stego = buildStego(passBytes, encryptedMsgBytes);// access the image's data as a byte arrayBufferedImage im = loadImage(imFnm);if (im == null)return false;byte imBytes[] = accessBytes(im);if (!singleHide(imBytes, stego))return false;// im is modified with the stego// store the modified image in Msg.pngString fnm = getFileName(imFnm);return writeImageToFile( fnm + "Msg.png", im);} // end of hide()One benefit of staying with LSB hiding, is that once the byte array holding the threepartstego message has been constructed (i.e. the stego[] array is filled), then the samesingleHide() method as in Steganongraphy can be employed to write it into theimage's data.genPassword() generates a 10-letter random string.// globalsprivate static final int PASSWORD_LEN = 10;private static Random rand = new Random(); //used for passwd genprivate static String genPassword(){String availChars ="abcdefghjklmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";// chars available for passwordStringBuffer sb = new StringBuffer(PASSWORD_LEN);for (int i=0; i

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!