import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Signature;

public class Utils {
	/**
	 * Try to get a Signature instance of the specified signing algorithm from
	 * the specified provider. Will terminate the program when it encounters
	 * related exceptions.
	 * 
	 * @param signAlgorithm
	 *            the signing algorithm
	 * @param provider
	 *            the provider for the Signature instance
	 * @return
	 */
	public static Signature getSignatureInstance(String signAlgorithm,
			String provider) {
		Signature signature = null;
		try {
			signature = Signature.getInstance(signAlgorithm, provider);
		} catch (NoSuchAlgorithmException e) {
			System.out.println("Can't find signature algorithm "
					+ signAlgorithm);
			System.exit(-1);
		} catch (NoSuchProviderException e) {
			System.out.println("Can't find provider " + provider);
			System.exit(-1);
		}
		return signature;
	}

	/**
	 * Try to get a KeyFactory instance of the specified key algorithm from the
	 * specified provider. Will terminate the program when it encounters related
	 * exceptions.
	 * 
	 * @param keyAlgorithm
	 *            the algorithm used to generate the keys
	 * @param provider
	 *            the provider for the KeyFactory instance
	 * @return
	 */
	public static KeyFactory getKeyFactoryInstance(String keyAlgorithm,
			String provider) {
		KeyFactory keyFactory = null;
		try {
			keyFactory = KeyFactory.getInstance(keyAlgorithm, provider);
		} catch (NoSuchAlgorithmException e) {
			System.out.println("Can't find key algorithm " + keyAlgorithm);
			System.exit(-1);
		} catch (NoSuchProviderException e) {
			System.out.println("Can't find provider " + provider);
			System.exit(-1);
		}
		return keyFactory;
	}

	/**
	 * Convert a String representation of hex values into binary representation.
	 * 
	 * @param s
	 *            String representation of the hex value
	 * @return binary representation of the hex value
	 */
	public static byte[] hexToByteArray(String s) {
		byte[] bytes = new byte[s.length() / 2];
		for (int i = 0; i < bytes.length; i++) {
			bytes[i] = (byte) Integer.parseInt(s.substring(2 * i, 2 * i + 2),
					16);
		}
		return bytes;
	}

	/**
	 * Convert a byte array into its String representation in hex value.
	 * 
	 * @param a the byte array to be converted
	 * @return String representation of the hex value
	 */
	public static String byteArrayToHex(byte[] a) {
		StringBuffer sb = new StringBuffer(a.length * 2);
		for (int i = 0; i < a.length; i++) {
			sb.append(Integer.toString(a[i] >>> 4, 16));
			sb.append(Integer.toString(a[i] & 0xf, 16));
		}
		return sb.toString();
	}

	public static void main(String[] args) {
		// Test
		String a = "abcd";
		System.out.println("a: " + a);
		byte[] b = a.getBytes();
		System.out.println("b: " + b);
		String c = byteArrayToHex(b);
		System.out.println("c: " + c);
		byte[] d = hexToByteArray(c);
		System.out.println("d: " + d);
		String e = new String(d);
		System.out.println("e: " + e);
	}
}

@@ -1,28 +1,49 @@
+import java.io.File;%0A
 import java.security.KeyFact
@@ -194,16 +194,780 @@
 Utils %7B%0A
+%09/**%0A%09 * Helper class for walking directory tree and do operations on file%0A%09 * encounter.%0A%09 * %0A%09 * @author shunghsiyu%0A%09 *%0A%09 */%0A%09static abstract class FileWalker %7B%0A%09%09String filepath;%0A%0A%09%09public FileWalker(String filepath) %7B%0A%09%09%09this.filepath = filepath;%0A%09%09%7D%0A%0A%09%09public void walk() %7B%0A%09%09%09walk(filepath, %22%22);%0A%09%09%7D%0A%0A%09%09private void walk(String filepath, String parent) %7B%0A%09%09%09File start = new File(filepath);%0A%09%09%09if (start.isDirectory()) %7B%0A%09%09%09%09File%5B%5D files = start.listFiles();%0A%0A%09%09%09%09for (File f : files) %7B%0A%09%09%09%09%09if (f.isDirectory()) %7B%0A%09%09%09%09%09%09walk(f.getAbsolutePath(), parent + %22/%22 + f.getName());%0A%09%09%09%09%09%7D else %7B%0A%09%09%09%09%09%09work(parent + %22/%22 + start + %22/%22 + f.getName());%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D%0A%09%09%09%7D else %7B%0A%09%09%09%09work(parent + %22/%22 + start);%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09abstract void work(String relativePath);%0A%09%7D%0A%0A
 %09/**%0A%09 *
@@ -3137,16 +3137,31 @@
 @param a
+%0A%09 *           
  the byt
@@ -3406,24 +3406,25 @@
 er.toString(
+(
 a%5Bi%5D %3E%3E%3E 4, 
@@ -3421,16 +3421,23 @@
 i%5D %3E%3E%3E 4
+) & 0xf
 , 16));%0A

Update Utils and fix bug in byteArrayToHex()