这个 钥匙() 方法 JAVA安全供应商 类用于返回此哈希表中键的枚举。
null
语法:
public Enumeration keys()
返回值: 此方法返回 密钥的枚举 在这个哈希表中。
下面是一些例子来说明 钥匙() 方法:
项目1:
JAVA
// Java program to demonstrate // keys() method import java.security.*; import java.util.*; public class GFG1 { public static void main(String[] argv) { // Declaring int variable int i = 10 ; try { // creating the object of SecureRandom SecureRandom sr = SecureRandom.getInstance( "NativePRNGBlocking" ); // getting the Provider of the SecureRandom sr // by using method getProvider() Provider provider = sr.getProvider(); // Declaring the variable of Enumeration<Object> type Enumeration<Object> enume; // getting the enumeration of the keys enume = provider.keys(); // printing the enumerated keys System.out.println( "enumeration of the values: " ); while (i > 0 ) { System.out.println( "Value is: " + enume.nextElement()); i--; } } catch (NoSuchAlgorithmException e) { System.out.println( "Exception thrown : " + e); } } } |
输出:
enumeration of the values: Value is: Alg.Alias.Signature.SHA1/DSAValue is: Alg.Alias.Signature.1.2.840.10040.4.3Value is: Alg.Alias.Signature.DSSValue is: SecureRandom.SHA1PRNG ImplementedInValue is: KeyStore.JKSValue is: Alg.Alias.MessageDigest.SHA-1Value is: MessageDigest.SHAValue is: KeyStore.CaseExactJKSValue is: CertStore.com.sun.security.IndexedCollection ImplementedInValue is: Signature.SHA256withDSA
例2:
JAVA
// Java program to demonstrate // keys() method import java.security.*; import java.util.*; public class GFG1 { public static void main(String[] argv) { // Declaring int variable int i = 10 ; try { // creating the object of Signature Signature sr = Signature.getInstance( "SHA1withDSA" ); // getting the Provider of the Signature sr // by using method getProvider() Provider provider = sr.getProvider(); // Declaring the variable of Enumeration<Object> type Enumeration<Object> enume; // getting the enumeration of the keys enume = provider.keys(); // printing the enumerated keys System.out.println( "enumeration of the values: " ); while (i > 0 ) { System.out.println( "Value is: " + enume.nextElement()); i--; } } catch (NoSuchAlgorithmException e) { System.out.println( "Exception thrown : " + e); } } } |
输出:
enumeration of the values: Value is: Alg.Alias.Signature.SHA1/DSAValue is: Alg.Alias.Signature.1.2.840.10040.4.3Value is: Alg.Alias.Signature.DSSValue is: SecureRandom.SHA1PRNG ImplementedInValue is: KeyStore.JKSValue is: Alg.Alias.MessageDigest.SHA-1Value is: MessageDigest.SHAValue is: KeyStore.CaseExactJKSValue is: CertStore.com.sun.security.IndexedCollection ImplementedInValue is: Signature.SHA256withDSA
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END