`
liulanghan110
  • 浏览: 1076766 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

Data must not be longer than 117 bytes异常

    博客分类:
  • JAVA
阅读更多

在利用数字证书加密时,会出现这样的异常 :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();
 
分享到:
评论

相关推荐

    Java 生成RSA密钥进行数据加密解密 支持超长字符分区

    在IT行业中,安全是至关重要的一个环节,尤其是在网络通信和数据传输中。Java作为一种广泛使用的编程语言,提供了丰富的安全库来处理加密任务。本篇主要介绍如何使用Java生成RSA密钥对,进行数据的加密与解密,以及...

    使用RSA生成公私钥对、加解密、及签名验签 JAVA源码.rar

    RSA算法是一种非对称加密算法,它在信息安全领域有着广泛的应用,特别是在数据加密、数字签名等方面。本资源提供了使用JAVA实现RSA公私钥对生成、数据加解密以及签名验签的源代码,非常适合学习和设计参考。...

    vue RSA加解密(完美解决加解密文本过长问题)

    rsa加解密

    微软内部资料-SQL性能优化2

    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...

    acpi控制笔记本风扇转速

    (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 ...

    S7A驱动720版本

    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 ...

    BURNINTEST--硬件检测工具

    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 ...

    微软内部资料-SQL性能优化5

    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....

    VclZip pro v3.10.1

    - 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 ...

    LCTF软件备份VariSpec™ Liquid Crystal Tunable Filters

    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 ...

    eac3to V3.17

    * 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...

    kgb档案压缩console版+源码

    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 ...

    Sakemail

    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 ...

    C PROGRAMMING TUTORIAL

    - **`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 ...

    servlet2.4doc

    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, ...

    Bochs - The cross platform IA-32 (x86) emulator

    --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 - ...

Global site tag (gtag.js) - Google Analytics