Java Signature getProvider() method with Examples

Java 8Object Oriented ProgrammingProgramming

The provider for the signature object can be obtained using the method getProvider() in the class java.security.Signature.

Let us now see an example −

Example

import java.security.*;
import java.util.*;
public class Main {
   public static void main(String[] argv) {
      try {
         Signature signature = Signature.getInstance("SHA256withRSA");
         Provider provider = signature.getProvider();
         System.out.println("The Provider is: " + provider);
      } catch (NoSuchAlgorithmException e) {
         System.out.println("Error!!! NoSuchAlgorithmException");
      }
   }
}

Output

The Provider is: SunRsaSign version 11

Example

Let us now see another example −

import java.security.*;
import java.util.*;
public class Main {
   public static void main(String[] argv) {
      try {
         Signature signature = Signature.getInstance("SHA1withDSA");
         Provider provider = signature.getProvider();
         System.out.println("The Provider is: " + provider);
      } catch (NoSuchAlgorithmException e) {
         System.out.println("Error!!! NoSuchAlgorithmException");
      }
   }
}

Output

The Provider is: SUN version 11
raja
Published on 23-Sep-2019 12:37:08
Advertisements