PBKDF2 function in Android

浪尽此生 提交于 2019-11-26 14:16:17

问题


Is there PBKDF2 implementation for Android. I am trying to derive a key using PBKDF2 function. I couldn't find an example to do so.


回答1:


Free options would be:

  • http://rtner.de/software/PBKDF2.html
  • http://bouncycastle.org/ (that might be newer than some Android-bundled org.bouncycastle)
  • http://www.unwesen.de/2011/06/12/encryption-on-android-bouncycastle/
  • https://github.com/rtyley/spongycastle#readme

IF a commercial component is an option see for example http://www.chilkatsoft.com/java-encryption.asp (sample code http://www.example-code.com/android/crypt2_pbkdf2.asp).

Another option is to use javax.crypto and implement it yourself although I wouldn't recommend that...




回答2:


Late to the party, but a lot of Android devices DO include PBKDF2 with the standard SecretKeyFactory. However, a lot of people recommend using something like Spongycastle to guarantee that you'll have that algorithm available.

It does throw an exception if it can't find one

    SecretKeyFactory keyFactory = null;
    try
    {
        keyFactory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
    } 
    catch (NoSuchAlgorithmException e)


来源:https://stackoverflow.com/questions/8091519/pbkdf2-function-in-android

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!