问题描述
出于某些原因,我需要使用 256 位块大小而不是使用 128 位块大小的 AES 来实现 Rijndael 解/压缩(原因:数据在 PHP 中使用 Rijndael 进行加密...).
For certain reasons I need to implement Rijndael de/compression with a blocksize of 256 bits instead of AES which uses a block size of 128 bits (reason: data is encrypted in PHP using Rijndael...).
如何更改密码的块大小?
How can I change the block-size for a cipher?
如果我只是用 "RIJNDAEL/CFB/PKCS5Padding"
得到一个密码并尝试用 256 位初始化一个 IV,我会得到一个异常,因为块大小只有 128 位.p>
If i just get a cipher with "RIJNDAEL/CFB/PKCS5Padding"
and try to initialize a IV with 256 bits I get an exception, because the block-size is only 128 bits.
推荐答案
除了 128 位块大小的 Rijndael 之外,任何 Sun JCE 提供程序都不支持:这是 AES 算法.要获得 256 位块大小的 rijndael,您将不得不去其他地方.我建议使用 Bouncycastle java 库.RijndaelEngine 类有一个构造函数接受以位为单位的块大小.大多数人发现 PaddedBufferedBlockCipher 类与合适的填充一起使用时更方便,例如
There is no support in any of the Sun JCE providers for anything other than Rijndael with the 128-bit blocksize: this is the AES algorithm. To get rijndael with the 256-bit blocksize you will have to go somewhere else. I suggest the Bouncycastle java library. The RijndaelEngine class has a constructor that accepts a block size in bits. Most people find the PaddedBufferedBlockCipher class to be more convenient when used with suitable padding, e.g.
PaddedBufferedBlockCipher c = new PaddedBufferedBlockCipher(new RijndaelEngine(256), new PKCS7Padding());
这篇关于如何使用 Rijndael 和 256 位的块大小进行加密或解密?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!