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 Java Signature getAlgorithm() method 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 Java Signature getAlgorithm() method with Examples The getAlgorithm() method of java.security.Signature class is used to return the name of the algorithm for this signature object.Syntax: public final String getAlgorithm() Return Value: This method returns the name of the algorithm for this signature object.Below are the examples to illustrate the g 1 min read SecureRandom getAlgorithm() method in Java with Examples The getAlgorithm() method of java.security.SecureRandom class is used to return the name of the algorithm implemented by this SecureRandom object.Syntax: public String getAlgorithm() Return Value: This method returns the name of the algorithm or unknown if the algorithm name cannot be determined.Bel 2 min read Provider.Service getAlgorithm() method in Java with Examples The getAlgorithm() method of java.security.Provider.Service class is used to return the standard name of the algorithm this Provider.Service is associated with. Syntax: public final String getAlgorithm() Return Value: This method returns name of the algorithm. Below are the examples to illustrate th 2 min read Like