Code example for IvParameterSpec

0
                throw new AssertionError(e);
            } 
        } 
 
        private static IvParameterSpec getRandomIV() {
            IvParameterSpec ivSpec = new IvParameterSpec(generateSalt(16));
            return ivSpec;
        } 
    } 
 
    public static byte[] generateSalt(int size) {
        byte[] salt = new byte[size];
        secureRandom.nextBytes(salt);
        return salt;
    } 
 
    public static String generateSaltBase64(int size) {
        byte[] salt = generateSalt(size);
        return Base64.encodeToString(salt, Base64.NO_WRAP);
    } 
}