I can't decrypt file with different salt and same password. Mybe I don't understand the concept. How does it work? Should I store static salt?
public static SecretKey getKeyFromPassword(String password) throws Exception {
byte[] salt = "123456".getBytes();
//SecureRandom random = new SecureRandom();
//random.nextBytes(salt);
SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256");
KeySpec spec = new PBEKeySpec(password.toCharArray(), salt, 65536, 256);
SecretKey secret = new SecretKeySpec(factory.generateSecret(spec).getEncoded(), "AES");
return secret;
}