package decrypt_singlebyte_xor;

/*
 * Util.java
 * /decrypt_singlebyte_xor/src/decrypt_singlebyte_xor/Util.java
 * Public domain - free to use
 * 
 */

import java.util.List;

public class Util {
	
	// ---- checkArg ------------------------------------------------------------------------------

	public static void checkArg(final String[] args, List<String> encodedStrings) {

		// 1. we must have one arg or more
		// 2. each arg must have an even number of chars
		// 3. return string to decrypt in encodedStrings
		
		if(args.length == 0) {
			System.out.println("decrypt_singlebyte_xor {encoded string} [...]");
			System.out.println();
			System.out.println("use : analyze and decrypt a single-char XORed encoded string");
			System.out.println("      each possible char is tried, character frequency is calculated");
			System.out.println("      outputs the highest score for english plaintext");
			System.out.println("      clear text is supposed to be ASCII-encoded");
			System.exit(0);
		}
		
		for(String s : args) {
			if(s.length() % 2 != 0) {
				System.out.print("ignored (invalid length) : ");
				System.out.println(s);
			}
			else {
				encodedStrings.add(s);
			}
		}
		
	}

}

@@ -205,16 +205,52 @@
 l %7B%0D%0A%09%0D%0A
+%09Util() %7B%0D%0A%09%09// constructor%0D%0A%09%7D%0D%0A%09%0D%0A
 %09// ----

add constructor to hide default one