try {
SecretKeyFactory skf = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA512");
PBEKeySpec spec = new PBEKeySpec(password.toCharArray(), salt, ITERATIONS, KEY_LENGTH);
SecretKey key = skf.generateSecret(spec);
byte[] result = key.getEncoded();
return result;
}
catch(NoSuchAlgorithmException | InvalidKeySpecException e) {
e.printStackTrace();
}