KeyFactory getAlgorithm() method in Java with Examples
The getAlgorithm() method of java.security.KeyFactory class is used to gets the name of the algorithm associated with this KeyFactory.
Syntax:
public final String getAlgorithm()
Return Value: This method returns the name of the algorithm associated with this KeyFactory.
Below are the examples to illustrate the getAlgorithm() method.
Example 1:
// Java program to demonstrate // getAlgorithm() method import java.security.*; import java.util.*; import java.security.spec.*; public class GFG1 { public static void main(String[] argv) throws Exception { try { // creating object of keyfactory KeyFactory keyFactory = KeyFactory.getInstance("DSA"); // getting the algortihm of KeyFactory // using getAlgorithm() method String algo = keyFactory.getAlgorithm(); // printing the algorithm System.out.println("Algortihm : " + algo); } catch (NoSuchAlgorithmException e) { System.out.println("Exception thrown : " + e); } catch (ProviderException e) { System.out.println("Exception thrown : " + e); } } } |
chevron_right
filter_none
Output:
Algortihm : DSA
Example 2:
// Java program to demonstrate // getAlgorithm() method import java.security.*; import java.util.*; import java.security.spec.*; public class GFG1 { public static void main(String[] argv) throws Exception { try { // creating object of keyfactory KeyFactory keyFactory = KeyFactory .getInstance("DiffieHellman"); // getting the algortihm of KeyFactory // using getAlgorithm() method String algo = keyFactory.getAlgorithm(); // printing the algorithm System.out.println("Algortihm : " + algo); } catch (NoSuchAlgorithmException e) { System.out.println("Exception thrown : " + e); } catch (ProviderException e) { System.out.println("Exception thrown : " + e); } } } |
chevron_right
filter_none
Output:
Algortihm : DiffieHellman
Recommended Posts:
- KeyFactory generatePrivate() method in Java with Examples
- KeyFactory generatePublic() method in Java with Examples
- KeyPairGenerator getAlgorithm() method in Java with Examples
- SecureRandom getAlgorithm() method in Java with Examples
- Java Signature getAlgorithm() method with Examples
- AlgorithmParameterGenerator getAlgorithm() method in Java with Examples
- Java lang.Long.numberOfLeadingZeros() method in Java with Examples
- Java lang.Long.highestOneBit() method in Java with Examples
- Java.util.Collections.rotate() Method in Java with Examples
- Java.util.Collections.disjoint() Method in java with Examples
- Java lang.Long.lowestOneBit() method in Java with Examples
- Java.lang.Short toString() method in Java with Examples
- Java lang.Long.numberOfTrailingZeros() method in Java with Examples
- Java lang.Long.byteValue() method in Java with Examples
- Java lang.Long.reverse() method in Java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



