Code example for PBEKeySpec

     * rejected. 
    public SecretKey genKeyPwkdf2(String password, byte[] salt, int iterations)
            throws NoSuchAlgorithmException, InvalidKeySpecException { 
        SecretKeyFactory f = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
        PBEKeySpec keySpec = new PBEKeySpec(password.toCharArray(), salt, iterations, KEY_BITS);
        SecretKey generatedKey = f.generateSecret(keySpec);
        return generatedKey;
     * Generates a random initialisation vector. 
     * @return A random initialisation vector. 
    public byte[] getIv() { 
        SecureRandom sr = new SecureRandom();
        byte[] iv = new byte[IV_BYTES];
        return iv;
Connect your IDE to all the code out there  Get Codota for Java