src/jpm/dg/RetrievingActivity.java
/**
	 * Decodes a String from an image.
	 * @param originalData The image data.
	 * @param key The password (possibly null).
	 * @param isRandom True if extraction should be for random/optimised algorithms.
	 * @return The message discovered (if any).
	 */
Decodes a String from an image.
@param originalData The image data.
@param key The password (possibly null).
@param isRandom True if extraction should be for random/optimised algorithms.
@return The message discovered (if any).
Decodes a String from an image . @param originalData The image data . @param key The password ( possibly null ) . @param isRandom True if extraction should be for random / optimised algorithms . @return The message discovered ( if any ) .
public String decodeMessage(int[] originalData, String key, boolean isRandom) {
		StringBuilder builder = new StringBuilder();
		int shiftIndex = 4;
		byte tmp = 0x00;
		Random rng = new Random(originalData[0]);
		boolean compressed = false;
		byte[] oneDPix = Util.convertArray(originalData);
		Set<Integer> usedElements = new HashSet<Integer>();
		usedElements.add(0);
		boolean msgEnded = false;
		int index = -1;
		while (!builder.toString().endsWith(END_MESSAGE_CONSTANT) && !msgEnded
				&& !decodingTask.isCancelled()) {
			if (isRandom) {
				index = 0;
				while (usedElements.contains(index)) {
					index = rng.nextInt(originalData.length);
				}
				usedElements.add(index);
			} else {
				index++;
			}
			for (int i = index * 3; i < (index * 3) + CHANNELS; i++) {
				tmp = (byte) (tmp | ((oneDPix[i] << SHIFT_VALUES[shiftIndex
						% SHIFT_VALUES.length]) & AND_BYTES[shiftIndex++
						% SHIFT_VALUES.length]));
				if (shiftIndex % SHIFT_VALUES.length == 0) {
					byte[] nonso = { tmp };
					String str;
					try {
						str = new String(nonso, "ISO-8859-1");
					} catch (UnsupportedEncodingException e) {
						str = "";
						e.printStackTrace();
					}
					if (builder.toString().endsWith(END_MESSAGE_CONSTANT)) {
						break;
					} else {
						builder.append(str);
						if (builder.toString().length() == START_MESSAGE_CONSTANT
								.length()) {
							if (START_MESSAGE_CONSTANT.equals(builder
									.toString())) {
								compressed = false;
							} else {
								if (START_COMPRESSED_CONSTANT.equals(builder
										.toString())) {
									compressed = true;
								} else {
									builder = null;
									msgEnded = true;
									break;
								}
							}
						}
					}
					tmp = 0x00;
				}
			}
		}
		return processMessage(builder, compressed, key);
	}
public String decodeMessage ( int [ ] originalData , String key , boolean isRandom ) { StringBuilder builder = new StringBuilder ( ) ; int shiftIndex = 4 ; byte tmp = 0x00 ; Random rng = new Random ( originalData [ 0 ] ) ; boolean compressed = false ; byte [ ] oneDPix = Util . convertArray ( originalData ) ; Set < Integer > usedElements = new HashSet < Integer > ( ) ; usedElements . add ( 0 ) ; boolean msgEnded = false ; int index = - 1 ; while ( ! builder . toString ( ) . endsWith ( END_MESSAGE_CONSTANT ) && ! msgEnded && ! decodingTask . isCancelled ( ) ) { if ( isRandom ) { index = 0 ; while ( usedElements . contains ( index ) ) { index = rng . nextInt ( originalData . length ) ; } usedElements . add ( index ) ; } else { index ++ ; } for ( int i = index * 3 ; i < ( index * 3 ) + CHANNELS ; i ++ ) { tmp = ( byte ) ( tmp | ( ( oneDPix [ i ] << SHIFT_VALUES [ shiftIndex % SHIFT_VALUES . length ] ) & AND_BYTES [ shiftIndex ++ % SHIFT_VALUES . length ] ) ) ; if ( shiftIndex % SHIFT_VALUES . length == 0 ) { byte [ ] nonso = { tmp } ; String str ; try { str = new String ( nonso , "ISO-8859-1" ) ; } catch ( UnsupportedEncodingException e ) { str = "" ; e . printStackTrace ( ) ; } if ( builder . toString ( ) . endsWith ( END_MESSAGE_CONSTANT ) ) { break ; } else { builder . append ( str ) ; if ( builder . toString ( ) . length ( ) == START_MESSAGE_CONSTANT . length ( ) ) { if ( START_MESSAGE_CONSTANT . equals ( builder . toString ( ) ) ) { compressed = false ; } else { if ( START_COMPRESSED_CONSTANT . equals ( builder . toString ( ) ) ) { compressed = true ; } else { builder = null ; msgEnded = true ; break ; } } } } tmp = 0x00 ; } } } return processMessage ( builder , compressed , key ) ; }
Decodes a String from an image.
Decodes a String from an image .