public String createPasswordKey(char[] password, byte[] salt, int iterations)
throws GeneralSecurityException {
if (hashAlgorithm != null) {
PBEKeySpec passwordKeySpec = new PBEKeySpec(password, salt, iterations, 256);
SecretKeyFactory secretKeyFactory = SecretKeyFactory.getInstance(hashAlgorithm);
SecretKey passwordKey = secretKeyFactory.generateSecret(passwordKeySpec);
passwordKeySpec.clearPassword();
return BinTools.bin2hex(passwordKey.getEncoded());
} else {
PBKDF2Parameters params = new PBKDF2Parameters("HmacSHA1", "ISO-8859-1", salt, iterations);
PBKDF2 pbkdf2 = new PBKDF2Engine(params);