Java中的KeyFactory getAlgorithm()方法
可以使用getAlgorithm()类java.security.KeyFactory中的方法获得KeyFactory的算法名称。此方法不需要任何参数,它返回KeyFactory的算法名称。
演示此的程序如下所示-
示例
import java.security.*;
import java.util.*;
import java.security.spec.*;
public class Demo {
public static void main(String[] argv) throws Exception {
try {
KeyFactory kf = KeyFactory.getInstance("RSA");
String algorithm = kf.getAlgorithm();
System.out.println("The Algortihm is: " + algorithm);
} catch (NoSuchAlgorithmException e) {
System.out.println("Error!!! NoSuchAlgorithmException");
} catch (ProviderException e) {
System.out.println("Error!!! ProviderException");
}
}
}输出结果
The Algorithm is: RSA
现在让我们了解上面的程序。
该方法getAlgorithm()用于获取KeyFactory的算法名称。然后显示此算法名称。如果算法名称错误,则会引发异常NoSuchAlgorithmException。演示的代码片段如下-
try {
KeyFactory kf = KeyFactory.getInstance("RSA");
String algorithm = kf.getAlgorithm();
System.out.println("The Algortihm is: " + algorithm);
} catch (NoSuchAlgorithmException e) {
System.out.println("Error!!! NoSuchAlgorithmException");
} catch (ProviderException e) {
System.out.println("Error!!! ProviderException");
}热门推荐
3 祝福语简短的微信
10 幼儿祝福语大全简短贺卡
11 感谢教官文案祝福语简短
12 鼠年同事祝福语简短创意
13 元旦祝福语 简短独特群发
14 妈咪跟我生日祝福语简短
15 给儿子新婚祝福语简短
16 伴娘祝福语长文案简短
17 恭喜高考完祝福语简短
18 生日祝福语送老公简短