Bouncy Castle scrypt实施 [英] Bouncy Castle scrypt implementation
问题描述
我目前正在使用 scrypt 实施密码哈希。我已经在GitHub上找到了一个很好的 scrypt 实现。令我惊讶的是,我还发现了一个 在Bouncy Castle图书馆实施scrypt 。这个类没有记录,维基百科没有提到Bouncy Castle作为scrypt实现提供程序,我找不到任何使用Bouncy Castles scrypt的人的代码示例,所以这看起来有点让我怀疑。
I'm currently implementing password hashing using scrypt. I have already found a nice scrypt implementation on GitHub. To my surprise I have also discovered a scrypt implementation in the Bouncy Castle library. The class is not documented, Wikipedia didn't mention Bouncy Castle as scrypt implementation provider and I had real trouble finding any code examples of someone using Bouncy Castles scrypt, so this looks somehow suspicious to me.
另一方面,如果我不得不在GitHubs加密实施和Bouncy Castle之间做出选择,我更喜欢Bouncy Castle。
On the other hand if I had to choose between a GitHubs crypto implementation and Bouncy Castle, I would prefer Bouncy Castle.
Bouncy城堡也是如此 scrypt '真实的东西'?我可以使用Bouncy Castles scrypt而不是JCA提供者API(或者我需要像这里一样直接调用它: AES-256加密工作流程在scala中使用充气城堡:盐和IV的使用和转移/存储)?
So is the Bouncy Castles scrypt the 'real thing'? And can I use Bouncy Castles scrypt over the JCA provider API (or do I need to call it directly like here: AES-256 encryption workflow in scala with bouncy castle: salt and IV usage and transfer/storage)?
编辑:我现在可以得到的最佳答案: https://www.bouncycastle.org/devmailarchive/msg13653.html
Best answer I could get by now: https://www.bouncycastle.org/devmailarchive/msg13653.html
推荐答案
因此人们不必去外部网站寻求答案:
So that people don't have to go to an external site for an answer:
- 确保充气城堡罐子是在您的构建路径上
-
像这样导入SCrypt:
- Make sure bouncy castle jars are on your build path
Import SCrypt like so:
import org.bouncycastle.crypto.generators.SCrypt;
像这样使用SCrypt:
Use SCrypt like so:
byte[] sCryptHash = SCrypt.generate(plaintext.getBytes(), salt.getBytes(), cpuDifficultyFactor, memoryDifficultyFactor, parallelismDifficultyFactor, outputLength);
这篇关于Bouncy Castle scrypt实施的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!