如何使用Rijndael加密或解密和256位的块大小? [英] How to encrypt or decrypt with Rijndael and a block-size of 256 bits?

查看:593
本文介绍了如何使用Rijndael加密或解密和256位的块大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某些原因,我需要使用256位的块大小来实现Rijndael de / compression,而不是使用块大小为128位的AES(原因:使用Rijndael ...在PHP中加密数据)。

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位。

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.

推荐答案

任何Sun JCE提供程序都不支持除Rijndael之外的128位块大小:这是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 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位的块大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆