public static String getMD5AsHex(byte[] key, int offset, int length) {
    try {
      MessageDigest md = MessageDigest.getInstance("MD5");
      md.update(key, offset, length);
      byte[] digest = md.digest();
      return new String(Hex.encodeHex(digest));
    } catch (NoSuchAlgorithmException e) {
      // this should never happen unless the JDK is messed up.
      throw new RuntimeException("Error computing MD5 hash", e);
    }
  }
Given a byte array, returns its MD5 hash as a hex string. Only "length" number of bytes
starting at "offset" within the byte array are used.
@param key the key to hash (variable length byte array)
@return MD5 hash as a 32 character hex string.
hbase-common/src/main/java/org/apache/hadoop/hbase/util/MD5Hash.java