getinstance java code example

Example 1: getinstance java

import java.security.*;
import java.util.*;
 
public class GFG1 {
    public static void main(String[] argv)
    {
        try {
            // creating the object of Signature and getting instance
            // By using getInstance() method
            Signature sr = Signature.getInstance("SHA1WithRSA");
 
            // getting the status of signature object
            String str = sr.toString();
 
            // printing the status
            System.out.println("Status : " + str);
        }
 
        catch (NoSuchAlgorithmException e) {
 
            System.out.println("Exception thrown : " + e);
        }
        catch (ProviderException e) {
 
            System.out.println("Exception thrown : " + e);
        }
    }
}

Example 2: getinstance java

import java.security.*;
import java.util.*;
 
public class GFG1 {
    public static void main(String[] argv)
    {
        try {
            // creating the object of Signature and getting instance
            // By using getInstance() method
            Signature sr = Signature.getInstance("SHA1WithRSA");
 
            // getting the status of signature object
            String str = sr.toString();
 
            // printing the status
            System.out.println("Status : " + str);
        }
 
        catch (NoSuchAlgorithmException e) {
 
            System.out.println("Exception thrown : " + e);
        }
        catch (ProviderException e) {
 
            System.out.println("Exception thrown : " + e);
        }
    }
}

Tags:

Java Example