private static byte [ ] pbkdf2 ( final char [ ] password , final byte [ ] salt , final int iterations , final int bytes ) { PBEKeySpec spec = new PBEKeySpec ( password , salt , iterations , bytes * 8 ) ; try { SecretKeyFactory skf = SecretKeyFactory . getInstance ( PBKDF2_ALGORITHM ) ; return skf . generateSecret ( spec ) . getEncoded ( ) ; } catch ( NoSuchAlgorithmException ignore ) { return null ; } catch ( InvalidKeySpecException e ) { throw new IllegalArgumentException ( e ) ; } }
Computes the PBKDF2 hash of a password .