Java 中的 `Provider keys()` 方法


可以使用 `java.security.Provider` 类中的 `keys()` 方法获取所需哈希表的键的枚举。此方法不需要参数,并且返回哈希表键的枚举。

演示此方法的程序如下 −

示例

 演示

import java.security.*;
import java.util.*;
public class Demo {
   public static void main(String[] argv) throws Exception {
      try {
         Signature sign = Signature.getInstance("DSA");
         Provider p = sign.getProvider();
         Enumeration<Object> enumeration = p.keys();
         System.out.println("The enumeration of the keys is as follows: 
");          int x = 30;          while (x > 0) {             System.out.println(enumeration.nextElement());             x--;          }       } catch (NoSuchAlgorithmException e) { System.out.println("Error!!! NoSuchAlgorithmException"); } } }

输出

The enumeration of the keys is as follows:
Alg.Alias.Signature.SHA1/DSA
Alg.Alias.Signature.1.2.840.10040.4.3
Alg.Alias.Signature.DSS
SecureRandom.SHA1PRNG ImplementedIn
KeyStore.JKS
Alg.Alias.MessageDigest.SHA-1
MessageDigest.SHA
KeyStore.CaseExactJKS
CertStore.com.sun.security.IndexedCollection ImplementedIn
Signature.SHA256withDSA
Alg.Alias.MessageDigest.OID.1.3.14.3.2.26
Alg.Alias.Signature.DSA
KeyFactory.DSA ImplementedIn
KeyStore.JKS ImplementedIn
AlgorithmParameters.DSA ImplementedIn
Signature.NONEwithDSA
Alg.Alias.CertificateFactory.X509
Signature.SHA256withDSA SupportedKeyClasses
CertStore.com.sun.security.IndexedCollection
Provider.id className
Alg.Alias.MessageDigest.1.3.14.3.2.26
Alg.Alias.Signature.SHA-1/DSA
KeyStore.DKS
CertificateFactory.X.509 ImplementedIn
Alg.Alias.Signature.OID.2.16.840.1.101.3.4.3.2
Alg.Alias.Signature.OID.2.16.840.1.101.3.4.3.1
Signature.SHA1withDSA KeySize
Signature.NONEwithDSA KeySize
CertPathValidator.PKIX ImplementedIn
KeyFactory.DSA

更新时间: 2019 年 7 月 30 日

91 次浏览

开启您的职业生涯

通过完成课程获得认证

立即开始
广告