PBKDF2 function in Android
Asked Answered
A

2

14

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.

Ataxia answered 11/11, 2011 at 8:45 Comment(0)
M
12

Free options would be:

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...

Marmara answered 11/11, 2011 at 8:57 Comment(0)
T
17

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)
Telescopic answered 2/4, 2013 at 17:18 Comment(2)
The following article includes an example method for the usage of SecretKeyFactory's PBKDF: android-developers.blogspot.de/2013/02/… (see section "Even more security").Birdlime
Works for Android API 10+, as documented at developer.android.com/reference/javax/crypto/… for anyone that wondersHofer
M
12

Free options would be:

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...

Marmara answered 11/11, 2011 at 8:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.