首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Data must not be longer than 117 bytes错误

2012-10-29 
Data must not be longer than 117 bytes异常在利用数字证书加密时,会出现这样的异常 :Data must not be l

Data must not be longer than 117 bytes异常

在利用数字证书加密时,会出现这样的异常 :Data must not be longer than 117 bytes。

解密时也会出现这样的异常。

?

解决办法是:分段加密和分段解密

?

代码如下:

// 解密时超过128字节就报错。为此采用分段解密的办法来解密StringBuilder sb = new StringBuilder();for (int i = 0; i < data.length; i += 128) {byte[] doFinal = cipher.doFinal(ArrayUtils.subarray(data, i,i + 128));sb.append(new String(doFinal));}dataReturn = sb.toString();
?

热点排行