是RC4还是ARCFOUR?使用SecretKeySpec时无效的KeyException? [英] Is it RC4 or ARCFOUR? InvalidKeyException when using SecretKeySpec?

查看:831
本文介绍了是RC4还是ARCFOUR?使用SecretKeySpec时无效的KeyException?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试过在我的电脑上运行我的应用程序,但我一直得到这个东西。是否可能缺少某些库?

I tried running my application on my pc, but I keep getting this thing. Is it possible that I'm missing some libraries?

fabsam.crypto.CryptoException: java.security.InvalidKeyException: No installed provider supports this key: javax.crypto.spec.SecretKeySpec
    at fabsam.crypto.RC4Decoder.decode(RC4Decoder.java:37) ~[bin/:na]
    ... (skipped my projects stack trace)
    at java.lang.Thread.run(Thread.java:662) [na:1.6.0_25]
Caused by: java.security.InvalidKeyException: No installed provider supports this key: javax.crypto.spec.SecretKeySpec
    at javax.crypto.Cipher.a(DashoA13*..) ~[na:1.6]
    at javax.crypto.Cipher.init(DashoA13*..) ~[na:1.6]
    at javax.crypto.Cipher.init(DashoA13*..) ~[na:1.6]
    at fabsam.crypto.RC4Decoder.decode(RC4Decoder.java:27) ~[bin/:na]
    ... 5 common frames omitted

Caused by: java.security.InvalidKeyException: No installed provider supports this key: javax.crypto.spec.SecretKeySpec
    at javax.crypto.Cipher.a(DashoA13*..) ~[na:1.6]
    at javax.crypto.Cipher.init(DashoA13*..) ~[na:1.6]
    at javax.crypto.Cipher.init(DashoA13*..) ~[na:1.6]
    at fabsam.crypto.RC4Decoder.decode(RC4Decoder.java:25) ~[fabsam-08.05.11.jar:na]
    ... 5 common frames omitted

代码:

cipher.init(Cipher.DECRYPT_MODE,
                    new SecretKeySpec(key.getBytes(DEFAULT_CHARSET), ALGORITHM));

可能是因为我使用 RC4 不是 ARCFOUR 在ALGORITHM变量中?
当我尝试ARCFOUR时,我得到:

Could it be because I'm using RC4 not ARCFOUR in the ALGORITHM variable? When I try ARCFOUR I get this:

fabsam.crypto.CryptoException: java.security.InvalidKeyException: Illegal key size or default parameters
    at fabsam.crypto.RC4Decoder.decode(RC4Decoder.java:37) ~[bin/:na]
    ... (skipped my projects stack trace)
    at java.lang.Thread.run(Thread.java:662) [na:1.6.0_25]
Caused by: java.security.InvalidKeyException: Illegal key size or default parameters
    at javax.crypto.Cipher.a(DashoA13*..) ~[na:1.6]
    at javax.crypto.Cipher.a(DashoA13*..) ~[na:1.6]
    at javax.crypto.Cipher.a(DashoA13*..) ~[na:1.6]
    at javax.crypto.Cipher.init(DashoA13*..) ~[na:1.6]
    at javax.crypto.Cipher.init(DashoA13*..) ~[na:1.6]
    at fabsam.crypto.RC4Decoder.decode(RC4Decoder.java:27) ~[bin/:na]
    ... 5 common frames omitted

好吧,问题不在于代码。在服务器上运行正常,没有错误。然而在我的电脑上,它抛出我InvalidKeyException异常。所以这是jvm相关的东西..任何想法?

Okay, the problem is not with the code. On server this runs just fine with no errors. However on my pc it throws me that InvalidKeyException exception. So it's something with jvm related.. Any ideas?

编辑:
我现在看到,不是一次,但第一次非法的密钥大小,然后没有安装提供程序。在运行我的项目时,我将ALGORITHM设置为ARCFOUR。

I now see that I'm getting both exceptions. Not at once, but first time the illegal key size and then no installed provider. I've the ALGORITHM set to "ARCFOUR" when running my project.

推荐答案

经过很多挣扎和搜索,得到了正确的答案。
在这里检查我的问题: Java安全性:非法密钥大小或默认参数?如果您遇到此问题!

After lot of struggling and searching and everything, I got the right answer. Check my question here: Java Security: Illegal key size or default parameters? if you are experiencing this problem!

这篇关于是RC4还是ARCFOUR?使用SecretKeySpec时无效的KeyException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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