public static String hash(String algorithm, String filepath) throws NoSuchAlgorithmException,
			IOException {
		MessageDigest md = MessageDigest.getInstance(algorithm);
		InputStream is = new FileInputStream(filepath);
		try {
			int numRead = 0;
			byte[] buffer = new byte[1024];
			while ((numRead = is.read(buffer)) > 0) {
				md.update(buffer, 0, numRead);
			}
		} finally {
			is.close();
		}
		return new String(encodeHex(md.digest()));
	}