MessageDigest getAlgorithm() method in Java with Examples Last Updated : 14 Oct, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The method getAlgorithm() of java.security.MessageDigest class is used to return the standard name of the algorithm this message digest is associated with. Syntax: public final String getAlgorithm() Return Value: This method returns the algorithm used in message digest. Below are the examples to illustrate the getAlgorithm() method: Example 1: Java // Java program to demonstrate // getAlgorithm() method import java.security.*; import java.util.*; public class GFG1 { public static void main(String[] argv) { try { // creating object of MessageDigest MessageDigest msd = MessageDigest.getInstance("MD5"); // get the name of algorithm // used in MessageDigest // using getAlgorithm() method String algo = msd.getAlgorithm(); // printing the string algo System.out.println("Algorithm : " + algo); } catch (NoSuchAlgorithmException e) { System.out.println("Exception thrown : " + e); } catch (ProviderException e) { System.out.println("Exception thrown : " + e); } } } Output: Algorithm : MD5 Example 2: Java // Java program to demonstrate // getAlgorithm() method import java.security.*; import java.util.*; public class GFG1 { public static void main(String[] argv) { try { // creating object of MessageDigest MessageDigest msd = MessageDigest.getInstance("SHA-256"); // get the name of algorithm used in MessageDigest // using getAlgorithm() method String algo = msd.getAlgorithm(); // printing the string algo System.out.println("Algorithm : " + algo); } catch (NoSuchAlgorithmException e) { System.out.println("Exception thrown : " + e); } catch (ProviderException e) { System.out.println("Exception thrown : " + e); } } } Output: Algorithm : SHA-256 Reference: https://docs.oracle.com/javase/9/docs/api/java/security/MessageDigest.html#getAlgorithm-- Comment More infoAdvertise with us Next Article MessageDigest getAlgorithm() method in Java with Examples R rohitprasad3 Follow Improve Article Tags : Java Java-Functions Java-security package Java-MessageDigest Practice Tags : Java Similar Reads MessageDigest getInstance() method in Java with Examples getInstance(String algorithm) The getInstance() method of java.security.MessageDigest class used to return a object of MessageDigest type that applies the assigned MessageDigest algorithm. Syntax: public static MessageDigest getInstance(String algorithm) throws NoSuchAlgorithmException Parameters: T 4 min read MessageDigest getDigestLength() method in Java with Examples The getDigestLength() method of MessageDigest class is used to get the size of object of message digest object in bytes. Syntax: public final int getDigestLength() Return Value: This method provides the length of the message digest in byte form. Below are the examples to illustrate the getDigestLeng 2 min read KeyPairGenerator getAlgorithm() method in Java with Examples The getAlgorithm() method of java.security.KeyPairGenerator class is used to return the standard name of the algorithm for this key pair generator. See the KeyPairGenerator section in the Java Cryptography Architecture Standard Algorithm Name Documentation for information about standard algorithm na 2 min read MessageDigest toString() method in Java with Examples The toString() method of java.security.MessageDigest class is used to provide the object of message digest in string format. Syntax: public String toString() Return Value: This method returns the object of message digest in string format. Below are the examples to illustrate the toString() method: E 2 min read List get() method in Java with Examples The get() method of List interface in Java is used to get the element present in this list at a given specific index. Example:Java// Java Program to demonstrate List // get() Method import java.util.*; class Main { public static void main (String[] args) { // Create a List List<Integer> a=new 2 min read Like