问题描述
2019 年更新:Bouncycastle 现在支持 PBKDF2-HMAC-SHA256,因为 bouncycastle 1.60
对于 JAVA 是否有可靠的 PBKDF2-HMAC-SHA256 实现?
Is there any reliable implementation of PBKDF2-HMAC-SHA256 for JAVA?
我曾经使用 bouncycastle 加密,但它不提供 PBKDF2WithHmacSHA256'.
I used to encrypt using bouncycastle but it does not provide PBKDF2WithHmacSHA256'.
我不想自己写加密模块.
I do not want to write crypto module by myself.
您能否推荐任何替代库或算法(如果我可以坚持使用 bouncycastle)
Could you recommend any alternative library or algorithm (if i can stick with bouncycastle)
(这里是 bouncycastle 支持的算法)http://www.bouncycastle.org/specifications.html
(here are the algorithms that bouncycastle supports) http://www.bouncycastle.org/specifications.html
推荐答案
直接使用 BouncyCastle 类:
Using BouncyCastle classes directly:
PKCS5S2ParametersGenerator gen = new PKCS5S2ParametersGenerator(new SHA256Digest());
gen.init("password".getBytes("UTF-8"), "salt".getBytes(), 4096);
byte[] dk = ((KeyParameter) gen.generateDerivedParameters(256)).getKey();
这篇关于PBKDF2-HMAC-SHA256 for JAVA 的可靠实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!