首页 > 其他 > 详细

加密时报InvalidKeyException问题

时间:2015-05-10 09:43:28      阅读:227      评论:0      收藏:0      [点我收藏+]

1.

使用DESedeKeySpec类时,抛了一个异常:InvalidKeyException!
看这个类的源码时才知道:/**
* Creates a new <code>DESedeKeySpec</code> instance from the first 24 (
* {@link #DES_EDE_KEY_LEN}) bytes of the specified key data.
*
* @param key
* the key data.
* @throws InvalidKeyException
* if the length of the key data is less than 24.
* @throws NullPointerException
* if the key data is null.
*/
public DESedeKeySpec(byte[] key) throws InvalidKeyException {
if (key == null) {
throw new NullPointerException("key == null");
}
if (key.length < DES_EDE_KEY_LEN) {
throw new InvalidKeyException();
}
this.key = new byte[DES_EDE_KEY_LEN];
System.arraycopy(key, 0, this.key, 0, DES_EDE_KEY_LEN);
}

代码注释中有句话 if the length of the key data is less than 24会抛异常throws InvalidKeyException ,也就是私钥的长度不能小于24位!

2.

公钥IvParameterSpec的长度必须是8位

加密时报InvalidKeyException问题

原文:http://blog.csdn.net/zouchengxufei/article/details/45618189

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!