SignTool { public static String sign(String toSign) throws NoSuchAlgorithmException { MessageDigest md = MessageDigest.getInstance("MD5"); md.update(toSign.getBytes()); StringBuilder key = new StringBuilder(); byte b[] = md.digest(); for (byte aB : b) { long t = aB < 0 ? 256 + aB : aB; key.append(Long.toHexString(t)); } return key.toString(); }  static String sign(String toSign);  }
@Test public void testSign() throws NoSuchAlgorithmException { String signature = sign("ABCD"); assertThat(signature, is("cb8ca4a7bb5f9683c19133a84872ca7")); }