问题描述
我想知道是否有人尝试过类似的
I was wondering if anyone have tried to do an equivalent of
Rfc2898DeriveBytes key = new Rfc2898DeriveBytes(secret, saltValueBytes);
byte[] secretKey = key.GetBytes(16);
在Java中.其中 secret 是一个字符串(密码),而 saltValueBytes 是字节数组中的盐.
in Java. Where secret is a string(password), and saltValueBytes is, well, a salt in byte array.
我尝试过一些东西,但似乎无法理解它.
I've tried stuff, but can't seem to wrap my head around it.
推荐答案
我找到了这个实现通过 Google 搜索,但我从未使用过.
I found this implementation by means of a Google search but I have never used it.
RFC 2898 的免费 Java 实现/PKCS#5 PBKDF2
似乎没有小而自由RFC 的可用 Java 实现2898/PKCS#5 可用.小如只有几个源文件,用微不足道的编译,无依赖,免费在 LGPL 中.
There seems to be no small and freely available Java implementation of RFC 2898 / PKCS#5 available. Small as in only a few source files, with trivial compile and no dependencies, free as in LGPL.
鉴于 HMacSHA1 在标准的 SUN JCE 密码提供者,这样的实现是很简单,可以从RFC 描述很字面意思.我的代码是一个洁净室实现仅以 RFC 为基础.
Given the availability of HMacSHA1 in the standard SUN JCE cryptographic provider, such an implementation is quite simple and can be derived from the RFC description quite literally. My code is a clean-room implementation with only the RFC as its basis.
这篇关于Java 相当于 C# 的 Rfc2898DerivedBytes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!