I am trying to encrypt a string in java with AES encryption using a password of any length. Here is my code so far but I do not understand it very well:
public static byte[] encrypt(String input, String salt) throws NoSuchAlgorithmException, NoSuchProviderException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException {
SecretKeySpec key = new SecretKeySpec(salt.getBytes(), "AES");
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding", "SunJCE");
cipher.init(Cipher.ENCRYPT_MODE, key);
return cipher.doFinal(input.getBytes());
}
How can I make a method to encrypt and decrypt a string of any length using a password of any length it. Also what is salt? I have been using the salt name for the password which only allows me to use a password of 16 characters.