可以使用getProvider()类java.security.Signature中的方法获得签名对象的提供程序。
现在让我们看一个例子-
示例import java.security.*;
import java.util.*;
public class Main {
public static void main(String[] argv) {
try {
Signature signature = Signature.getInstance("SHA256withRSA");
Provider provider = signature.getProvider();
System.out.println("The Provider is: " + provider);
} catch (NoSuchAlgorithmException e) {
System.out.println("Error!!! NoSuchAlgorithmException");
}
}
}
输出结果The Provider is: SunRsaSign version 11
示例
现在让我们来看另一个示例-import java.security.*;
import java.util.*;
public class Main {
public static void main(String[] argv) {
try {
Signature signature = Signature.getInstance("SHA1withDSA");
Provider provider = signature.getProvider();
System.out.println("The Provider is: " + provider);
} catch (NoSuchAlgorithmException e) {
System.out.println("Error!!! NoSuchAlgorithmException");
}
}
}
输出结果The Provider is: SUN version 11