code: public static String hmacDigest(String msg, String keyString, String algo) {
  		String digest = null;
  		try {
  			SecretKeySpec key = new SecretKeySpec(
  			        (keyString).getBytes("UTF-8"), algo);
  			Mac mac = Mac.getInstance(algo);
  			mac.init(key);
  
  			byte[] bytes = mac.doFinal(msg.getBytes("ASCII"));
  
  			StringBuilder hash = new StringBuilder();
  			
  			for (int i = 0; i < bytes.length; i++) {
  				String hex = Integer.toHexString(0xFF & bytes[i]);
  				if (hex.length() == 1) {
  					hash.append('0');
  				}
  				hash.append(hex);
  			}
  			digest = hash.toString();
  
  		} catch (Exception e) {
  			return null;
  		}
  
  		return digest;
  	}
docs: http://www.supermind.org/blog/1102/generating-hmac-md5-sha1-sha256-etc-in-java