Provider getName() method in Java with Examples
Last Updated :
17 Jan, 2023
The getName() method of java.security.Provider class is used to return the name of this provider.
Syntax:
public String getName()
Return Value: This method returns the name of this provider.
Below are the examples to illustrate the getName() method:
Example 1:
Java
import java.security.*;
import java.util.*;
public class GFG1 {
public static void main(String[] argv) throws Exception
{
try {
KeyPairGenerator sr = KeyPairGenerator.getInstance("DSA", "SUN");
Provider provider = sr.getProvider();
String name = provider.getName();
System.out.println("name : " + name);
}
catch (NoSuchAlgorithmException e) {
System.out.println("Exception thrown : " + e);
}
}
}
|
Example 2:
Java
import java.security.*;
import java.util.*;
public class GFG1 {
public static void main(String[] argv) throws Exception
{
try {
SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
Provider provider = sr.getProvider();
String name = provider.getName();
System.out.println("name : " + name);
}
catch (NoSuchAlgorithmException e) {
System.out.println("Exception thrown : " + e);
}
}
}
|
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...