code: public static byte[] digestString(String string,
                                        String encoding)
          throws RuntimeException {
  
          byte[] data;
  
          if (encoding == null) {
              encoding = "ISO-8859-1";
          }
  
          try {
              data = string.getBytes(encoding);
          } catch (UnsupportedEncodingException x) {
              throw new RuntimeException(x.toString());
          }
  
          return digestBytes(data);
      }
docs: Retrieves a byte sequence representing the MD5 digest of the
  specified character sequence, using the specified encoding to
  first convert the character sequence into a byte sequence.
  If the specified encoding is null, then ISO-8859-1 is
  assumed.
  
  @param string the string to digest.
  @param encoding the character encoding.
  @return the digest as an array of 16 bytes.
  @throws RuntimeException if an MD5 digest
  algorithm is not available through the
  java.security.MessageDigest spi or the requested
  encoding is not available