在利用数字证书加密时,会出现这样的异常 :Data must not be longer than 117 bytes。
解密时也会出现这样的异常。
解决办法是:分段加密和分段解密
代码如下:
// 加密时超过117字节就报错。为此采用分段加密的办法来加密
StringBuilder sb = new StringBuilder();
for (int i = 0; i < data.length; i += 100) {
byte[] doFinal = cipher.doFinal(ArrayUtils.subarray(data, i,
i + 100));
sb.append(new String(doFinal));
dataReturn = ArrayUtils.addAll(dataReturn, doFinal);
}
// 解密时超过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();
分享到:
相关推荐
在IT行业中,安全是至关重要的一个环节,尤其是在网络通信和数据传输中。Java作为一种广泛使用的编程语言,提供了丰富的安全库来处理加密任务。本篇主要介绍如何使用Java生成RSA密钥对,进行数据的加密与解密,以及...
RSA算法是一种非对称加密算法,它在信息安全领域有着广泛的应用,特别是在数据加密、数字签名等方面。本资源提供了使用JAVA实现RSA公私钥对生成、数据加解密以及签名验签的源代码,非常适合学习和设计参考。...
rsa加解密
To reserve or commit memory and unintentionally not release it when it is no longer being used. A process can leak resources such as process memory, pool memory, user and GDI objects, handles, threads...
(Region must be of type SystemMemory, see below.) Fixed the Load ASL operator for the case where the source operand is a region field. A buffer object is also allowed as the source operand. BZ 480 ...
logical name of the driver device, which is requested, must be entered . Example: "!switch:D11" delivers the state of the driver device with the name "D11". This function is also available via ...
Users must have administrator privileges. Windows 98 and Windows ME ========================= Windows 98 and ME are not supported in BurnInTest version 5.3 and above. Use a version of BurnInTest ...
If even one column in the query is not part of the index, the data rows must be accessed. The leaf level of an index is the only level that contains every key value, or set of key values. For a ...
While the tablet interface design must address the technical problems stated above, it must also be useful to the programmers who will write tablet programs, and ultimately, to the tablet users....
- Uncompressed, Compressed, and Archive file sizes can be up to 2^63-1 bytes in length. - You can compress up to 2147483647 files into an archive. This is compatible with PKZip's Zip64 format. - If ...
Whereas, if three users transmit simultaneously, the bandwidth required will be 3Mbps which is more than the available bandwidth of the shared link. In this case, there will be queuing delay ...
While it appears to be present at either 9600 baud or 115.2 kbaud , the actual data transmission occurs at 12 MBaud over the USB. Each command is terminated with an end-of-line terminator which can ...
* fixed: error code not set for "source file format could not be detected" * fixed: audio resampling from/to 24.975 didn't work properly * fixed: WAV files beginning with lots of zeroes were sometimes...
The archive must not already exist. File names may specify a path, which is stored. If there are no file names on the command line, then PAQ6 prompts for them, reading until the first blank line or ...
A obscure bug was found by HuangYeJun from china, in the RetrieveHeaders function if the retrieved text was larger than 1024 bytes and the crlf.crlf fall in the middle of two chunks, the function is ...
- **`sizeof`:** Returns the size of a variable or a data type in bytes. - **`?:`:** Conditional (ternary) operator. #### Operators Precedence in C Operators have a specific precedence that ...
Causes the next filter in the chain to be invoked, or if the calling filter is the last filter in the chain, causes the resource at the end of the chain to be invoked. doFilter(ServletRequest, ...
--enable-vmx=2 option (x86-64 must be enabled) - Bugfixes for CPU emulation correctness - Fixed Bochs crash when accessing the first byte above emulated memory size - Internal Debugger - ...