推荐园子里的一篇博文:关于PKCS5Padding与PKCS7Padding的区别
多谢,文章已看能否给出aes加密方法能让C#和Java通过。
@老三的古代: 是想实现Java中AES加密,C#中ACE解密或者反之吗?
@dudu: 是的,现在两方出现不对称的情况.
@老三的古代: 试试AES Crypt
@dudu: 多谢,目前采用无偏移解决问题,但是降低了复杂度,先这样吧。
PKCS7[edit]
PKCS#7 is described in RFC 5652.
Padding is in whole bytes. The value of each added byte is the number of bytes that are added, i.e. N bytes, each of value N are added. The number of bytes added will depend on the block boundary to which the message needs to be extended.
The padding will be one of:
01 02 02 03 03 03 04 04 04 04 05 05 05 05 05 etc.
This padding method (as well as the previous two) is well-defined if and only if N is less than 256.
Example: In the following example the block size is 8 bytes and padding is required for 4 bytes
... | DD DD DD DD DD DD DD DD | DD DD DD DD 04 04 04 04 |
If the original data is a multiple of N bytes, then an extra block of bytes with value N is added.
PKCS#5 padding is identical to PKCS#7 padding, except that it has only been defined for block ciphers that use a 64-bit (8 byte) block size. In practice the two can be used interchangeably.
看不懂,用机器翻译了一下。
@老三的古代: 最简单的情况,如果加密操作的块大小为 64 位(8字节)时,PKCS#5 同 PKCS#7 填充结果一致。
@Launcher: 多谢.