Issue
I'm trying to use Luke Joshua Park SecureCompatibleEncryptionExamples on android. My problem is that PBKDF2WithHmacSHA256 is not available for android below API 26. Any way to get around this?
Solution
Android doesn't support PBKDF2withHmacSHA256
before API 26, but it does support PBKDF2withHmacSHA1
in older versions. Unless there is a specific reason you want to use SHA256 as the PBKDF2 hash, there is no harm in changing this.
The algorithms in my repository can be changed relatively easily by adjusting the PBKDF2_NAME
parameter. SHA1 is still safe to use with PBKDF2, so you could simply adjust:
private final static String PBKDF2_NAME = "PBKDF2WithHmacSHA256";
To:
private final static String PBKDF2_NAME = "PBKDF2WithHmacSHA1";
In your Android code and in your PHP change:
define("PBKDF2_NAME", "sha256");
To:
define("PBKDF2_NAME", "sha1");
Also of note, if you're using this as transport security, you shouldn't be. You should be using TLS.
Answered By - Luke Joshua Park