Java签名getAlgorithm()方法与示例
可以使用getAlgorithm()类java.security.Signature中的方法获得签名对象的算法名称。
现在让我们看一个例子-
示例
import java.security.*;
import java.util.*;
public class Main {
public static void main(String[] argv) {
try {
Signature signature = Signature.getInstance("SHA256withRSA");
String algorithm = signature.getAlgorithm();
System.out.println("The Algorithm = " + algorithm);
} catch (NoSuchAlgorithmException e) {
System.out.println("Error!! NoSuchAlgorithmException");
}
}
}输出结果
The Algorithm = SHA256withRSA
现在让我们来看另一个示例-
示例
import java.security.*;
import java.util.*;
public class Main {
public static void main(String[] argv) {
try {
Signature signature = Signature.getInstance("SHA1withDSA");
String algorithm = signature.getAlgorithm();
System.out.println("The Algorithm = " + algorithm);
} catch (NoSuchAlgorithmException e) {
System.out.println("Error!! NoSuchAlgorithmException");
}
}
}输出结果
The Algorithm = SHA1withDSA
热门推荐
10 小侄过生日祝福语简短
11 小店营业的祝福语简短
12 担任老师的祝福语简短
13 饮料吧台祝福语简短大气
14 公司新春搞笑祝福语简短
15 高情商敬酒祝福语简短
16 婚礼祝福语新郎妹妹简短
17 教师答辩通过祝福语简短
18 生女孩红包简短祝福语