关于cryptix JCE的配置使用

kexsong 2005-03-30 03:26:13
我根据网上的文章,下载了cryptix-jce-20050328-snap.zip并且解压和把里面的jar包放在了jdk的相应目录下,也设置了它们的CLASSPATH,同时设置了java.security文件,片段如下:
...
security.provider.1=sun.security.provider.Sun
security.provider.2=com.sun.net.ssl.internal.ssl.Provider
security.provider.3=com.sun.rsajca.Provider
security.provider.4=com.sun.crypto.provider.SunJCE
security.provider.5=sun.security.jgss.SunProvider
security.provider.6=cryptix.jce.provider.cipher.TripleDES
...
网上的例子是这样的:
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;

public class Simple3DES
{

public static void main(String[] args)
{

try
{
String sKey = "123456789012345678901234";

SecretKeySpec skeySpec = new SecretKeySpec(sKey.getBytes(),
"TripleDES");
Cipher cipher = Cipher.getInstance("TripleDES");
cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
byte[] cleartext = "testcontent".getBytes();
byte[] encrypted = cipher.doFinal(cleartext, 0, cleartext.length);
StringBuffer sb = new StringBuffer();
for ( int j = 0; j < encrypted.length; j++ )
{
int k = encrypted[j];
if ( k < 0 )
k += 256;
sb.append("%" + Integer.toHexString(k).toUpperCase());
}
System.err.println("result:" + sb.toString());
}
catch ( Exception e )
{
System.err.println("Caught exception " + e.toString());
}

}

}
但是,当我运行的时候,总是说:Caught exception java.security.NoSuchAlgorithmException: Cannot find any provider supporting TripleDES。
请问,我还要怎么配置呢?或者我应该怎样结合jdk使用cryptix JCE呢?因为我是新手,谢谢大家指点!
...全文
147 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
kexsong 2005-04-06
  • 打赏
  • 举报
回复
自己解决
OnlyFor_love 2005-04-05
  • 打赏
  • 举报
回复
好象很有难度啊!

我是初学者,只能帮你顶一下
kexsong 2005-04-05
  • 打赏
  • 举报
回复
没人用过?分不够?
kexsong 2005-04-01
  • 打赏
  • 举报
回复
没人知道吗?
OnlyFor_love 2005-03-31
  • 打赏
  • 举报
回复
没用过!不太了解!
帮你顶一下吧

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧