问题描述
我们需要用 Java 进行一些 Rijndael 开发.
We have a requirement to do some Rijndael development in Java.
对我们有帮助的文章、图书馆等有什么建议吗?
Any recommendations for articles, libraries etc. that would help us?
任何指向密钥库维护以及如何安全存储密钥的指针?
Any pointers to keystore maintenance and how store the keys securely?
它需要是开源的.本质上,它只是使用 Rijndael 对数据进行标准加密/解密.
It would need to be open source. Essentially, it's just standard encrypt / decrypt of data using Rijndael.
推荐答案
Java 包含开箱即用的 AES.Rijndael 是 AES.您不需要任何外部库.你只需要这样的东西:
Java includes AES out of the box. Rijndael is AES. You don't need any external libraries. You just need something like this:
byte[] sessionKey = null; //Where you get this from is beyond the scope of this post
byte[] iv = null ; //Ditto
byte[] plaintext = null; //Whatever you want to encrypt/decrypt
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
//You can use ENCRYPT_MODE or DECRYPT_MODE
cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(sessionKey, "AES"), new IvParameterSpec(iv));
byte[] ciphertext = cipher.doFinal(plaintext);
就是这样,用于加密/解密.如果您正在处理大量数据,那么您最好读取 16 字节的倍数的块并调用 update 而不是 doFinal(您只需在最后一个块上调用 doFinal).
And that's it, for encryption/decryption. If you are processing large amounts of data then you're better off reading chunks that are multiples of 16 bytes and calling update instead of doFinal (you just call doFinal on the last block).
这篇关于Java 中的 Rijndael 支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)