如何列出可用的密码算法? [英] How can I list the available Cipher algorithms?

查看:173
本文介绍了如何列出可用的密码算法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到一个Cipher实现与 Cipher.getInstance(String algorithm)。我的印象是,我可能传递的可用的算法名称根据我的类路径中存在的库是不同的。

I am getting a Cipher implementation with Cipher.getInstance(String algorithm). I am under the impression that the available algorithm names that I may pass differ based on what libraries which are present in my classpath.

我想写一个简单的程序我可以运行不同的类路径,将列出可用的密码算法名称。

I would like to write a simple program that I can run with different classpaths that will list the available Cipher algorithm names. What method would I need to call to get this list?

推荐答案

我有一个提供者列表,如JB Nizet的post,我还没有一个算法列表。我发现每个提供者作为一个Properties对象,属性编码的算法名称。我不完全清楚如果这是正确的方式寻找他们或不是,什么所有其他属性的意思,但我只是写了一个例程,喷出所有属性到System.out和grepped各种字符串描述什么我一直在寻找,直到我找到它。

Once I have a list of providers, as described in JB Nizet's post, I still don't have a list of algorithms. I found that each Provider functions as a Properties object, and the Properties encode the algorithm names. I'm not entirely clear on if this is the correct way to look for them or not, and what exactly all the other properties mean, but I just wrote a routine that spewed all properties to System.out and grepped for various strings describing what I was looking for until I found it.

import java.security.*;

for (Provider provider: Security.getProviders()) {
  System.out.println(provider.getName());
  for (String key: provider.stringPropertyNames())
    System.out.println("\t" + key + "\t" + provider.getProperty(key));
}

这篇关于如何列出可用的密码算法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆