DigestUtilities { public static Set<String> getMessageDigestAlgorithmNames() { Set<String> algNames = new HashSet<String>(); for (Provider prov : Security.getProviders()) { Set<Object> keys = prov.keySet(); for (Object objKeyPair : keys) { String strKeyPair = (String) objKeyPair; String key = strKeyPair.split(" ")[0]; if (key.startsWith(JAVA_SECURITY_ALG_ALIAS_PREFIX)) { key = key.substring(JAVA_SECURITY_ALG_ALIAS_PREFIX.length()); } if (key.startsWith(JAVA_SECURITY_DIGEST_PREFIX)) { algNames.add(key.substring(JAVA_SECURITY_DIGEST_PREFIX.length() + 1)); } } } return algNames; } private  DigestUtilities(); static final String byteDigestToHexString(byte[] digest); static byte[] hexStringToByteArray(String hexVal); static Set<String> getMessageDigestAlgorithmNames();  }
@Test public void testGetMessageDigestAlgorithmNames() { Set<String> algNames = DigestUtilities.getMessageDigestAlgorithmNames(); for (DigestAlgorithm alg : DigestAlgorithm.values()) { assertTrue("Java standard name " + alg.getJavaName() + " should be in digest set", algNames.contains(alg.getJavaName())); } }