Example usage for java.security MessageDigest getProvider

List of usage examples for java.security MessageDigest getProvider

Introduction

In this page you can find the example usage for java.security MessageDigest getProvider.

Prototype

public final Provider getProvider() 

Source Link

Document

Returns the provider of this message digest object.

Usage

From source file:test.unit.test.be.fedict.eid.applet.model.XmlSignatureServiceBeanTest.java

@Test
public void testRegisterOwnJceProvider() throws Exception {
    MyTestProvider provider = new MyTestProvider();
    assertTrue(-1 != Security.addProvider(provider));

    MessageDigest messageDigest = MessageDigest.getInstance("SHA-1", MyTestProvider.NAME);
    assertEquals(MyTestProvider.NAME, messageDigest.getProvider().getName());

    messageDigest.update("hello world".getBytes());
    byte[] result = messageDigest.digest();

    Assert.assertArrayEquals("hello world".getBytes(), result);

    Security.removeProvider(MyTestProvider.NAME);
}