Applications can access the capabilities of a digital signature algorithm using the Signature
class. To authenticate and guarantee the integrity of digital data, digital signatures are utilized.
The getInstance()
method is a static method of the Signature
class that returns an instance of the Signature
class that implements the specified signature algorithm. The signature algorithm can be specified as a string or as an implementation of the Provider
class. The method throws NoSuchAlgorithmException
if the specified algorithm or provider is not available.
public static Signature getInstance(String algorithm)
algorithm
: This is the name of the signature algorithm.The method returns a Signature
object.
import java.security.*;public class Main{public static void main(String[] args) {try {String algorithm = "SHA224withRSA";Signature signature = Signature.getInstance(algorithm);System.out.println("Signature object : " + signature.toString());} catch (NoSuchAlgorithmException e) {System.out.println("Exception : " + e);}}}
Signature
class using the getInstance()
method by specifying the algorithm defined in Line 7.NoSuchAlgorithmException
exception and print it.Free Resources