code: public static String md5Encode(String strIn) {
          try {
              MessageDigest md5 = MessageDigest.getInstance("md5");
              byte[] bin = toBytes(strIn);
              byte[] bout = md5.digest(bin);
              String strOut = javax.xml.bind.DatatypeConverter.printBase64Binary(bout);
              return strOut;
          }catch (Exception e) {
              throw new RuntimeException(e.getMessage(), e);
          }
      }
docs: Compute the MD5 of the given string and return it as a Base64-encoded value. The
  string is first converted to bytes using UTF-8, and the MD5 is computed on that
  value. The MD5 value is 16 bytes, but the Base64-encoded string is 24 chars.
  
  @param strIn A Unicode string.
  @return      Base64-encoded value of the strings UTF-8 encoded value.