use of org.apache.xml.security.algorithms.MessageDigestAlgorithm in project santuario-java by apache.
the class DigestAlgorithmTest method testSHA1.
@org.junit.Test
public void testSHA1() throws Exception {
Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
MessageDigestAlgorithm digestAlgorithm = MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA1);
assertEquals(MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA1, digestAlgorithm.getAlgorithmURI());
byte[] digest = digestAlgorithm.digest("test-string".getBytes());
assertNotNull(digest);
assertTrue(digest.length > 0);
// Now compare against a JDK MessageDigest Object
MessageDigest md = MessageDigest.getInstance("SHA-1");
byte[] digest2 = md.digest("test-string".getBytes());
assertTrue(Arrays.equals(digest, digest2));
}
use of org.apache.xml.security.algorithms.MessageDigestAlgorithm in project santuario-java by apache.
the class DigestAlgorithmTest method testSHA224.
@org.junit.Test
public void testSHA224() throws Exception {
Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
MessageDigestAlgorithm digestAlgorithm = MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA224);
assertEquals(MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA224, digestAlgorithm.getAlgorithmURI());
byte[] digest = digestAlgorithm.digest("test-string".getBytes());
assertNotNull(digest);
assertTrue(digest.length > 0);
// Now compare against a JDK MessageDigest Object
MessageDigest md = MessageDigest.getInstance("SHA-224");
byte[] digest2 = md.digest("test-string".getBytes());
assertTrue(Arrays.equals(digest, digest2));
}
use of org.apache.xml.security.algorithms.MessageDigestAlgorithm in project santuario-java by apache.
the class DigestAlgorithmTest method testRIPEMD160.
@org.junit.Test
public void testRIPEMD160() throws Exception {
org.junit.Assume.assumeTrue(bcInstalled);
Document doc = XMLUtils.createDocumentBuilder(false).newDocument();
MessageDigestAlgorithm digestAlgorithm = MessageDigestAlgorithm.getInstance(doc, MessageDigestAlgorithm.ALGO_ID_DIGEST_RIPEMD160);
assertEquals(MessageDigestAlgorithm.ALGO_ID_DIGEST_RIPEMD160, digestAlgorithm.getAlgorithmURI());
byte[] digest = digestAlgorithm.digest("test-string".getBytes());
assertNotNull(digest);
assertTrue(digest.length > 0);
// Now compare against a JDK MessageDigest Object
MessageDigest md = MessageDigest.getInstance("RIPEMD160");
byte[] digest2 = md.digest("test-string".getBytes());
assertTrue(Arrays.equals(digest, digest2));
}
Aggregations