code: public static MessageDigest getInstance(String algorithm, String provider)
          throws NoSuchAlgorithmException, NoSuchProviderException
      {
          if (provider == null || provider.length() == 0)
              throw new IllegalArgumentException("missing provider");
          Object[] objs = Security.getImpl(algorithm, "MessageDigest", provider);
          if (objs[0] instanceof MessageDigest) {
              MessageDigest md = (MessageDigest)objs[0];
              md.provider = (Provider)objs[1];
              return md;
          } else {
              MessageDigest delegate =
                  new Delegate((MessageDigestSpi)objs[0], algorithm);
              delegate.provider = (Provider)objs[1];
              return delegate;
          }
      }
docs: Returns a MessageDigest object that implements the specified digest
  algorithm.
  
  <p> A new MessageDigest object encapsulating the
  MessageDigestSpi implementation from the specified provider
  is returned.  The specified provider must be registered
  in the security provider list.
  
  <p> Note that the list of registered providers may be retrieved via
  the {@link Security#getProviders() Security.getProviders()} method.
  
  @param algorithm the name of the algorithm requested.
  See the MessageDigest section in the <a href=
  "{@docRoot}openjdk-redirect.html?v=8&path=/technotes/guides/security/StandardNames.html#MessageDigest">
  Java Cryptography Architecture Standard Algorithm Name Documentation</a>
  for information about standard algorithm names.
  
  @param provider the name of the provider.
  
  @return a MessageDigest object that implements the specified algorithm.
  
  @exception NoSuchAlgorithmException if a MessageDigestSpi
  implementation for the specified algorithm is not
  available from the specified provider.
  
  @exception NoSuchProviderException if the specified provider is not
  registered in the security provider list.
  
  @exception IllegalArgumentException if the provider name is null
  or empty.
  
  @see Provider