PBKDF2 function in Android

ssk picture ssk · Nov 11, 2011 · Viewed 15.1k times · Source

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.

Answer

Joe Plante picture Joe Plante · Apr 2, 2013

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)