問(wèn)題描述
2019 年更新:Bouncycastle 現(xiàn)在支持 PBKDF2-HMAC-SHA256,因?yàn)?bouncycastle 1.60
對(duì)于 JAVA 是否有可靠的 PBKDF2-HMAC-SHA256 實(shí)現(xiàn)?
Is there any reliable implementation of PBKDF2-HMAC-SHA256 for JAVA?
我曾經(jīng)使用 bouncycastle 加密,但它不提供 PBKDF2WithHmacSHA256'.
I used to encrypt using bouncycastle but it does not provide PBKDF2WithHmacSHA256'.
我不想自己寫(xiě)加密模塊.
I do not want to write crypto module by myself.
您能否推薦任何替代庫(kù)或算法(如果我可以堅(jiān)持使用 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();
這篇關(guān)于PBKDF2-HMAC-SHA256 for JAVA 的可靠實(shí)現(xiàn)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!