Java tutorial
//package com.java2s; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; public class Main { static MessageDigest createDigestInstance(String digestName, String provider) throws NoSuchAlgorithmException, NoSuchProviderException { if (provider == null) { return MessageDigest.getInstance(digestName); } return MessageDigest.getInstance(digestName, provider); } }