問題描述
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 的可靠實現的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!