title: How to use openssl to decrypt data encrypted by Java using AES
body: <p>I am generating an AES public key and IV (Initialization Vector) in Java to encrypt data. I need to decrypt this using <code>openssl</code> command. Is this possible given that I store the AES Key and the IV on the disk?</p>
  
  <p>Following is the encryption logic</p>
  
  <pre><code>    Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
      cipher.init(Cipher.ENCRYPT_MODE, key, iv);
      byte[] stringBytes = pass.getBytes();
      byte[] raw = cipher.doFinal(stringBytes);
      return Base64.encodeBase64String(raw);
  </code></pre>
  
  <p>Generating the AES Key</p>
  
  <pre><code>   SecretKey secret_key = KeyGenerator.getInstance("AES").generateKey();
  </code></pre>
  
  <p>Generating the IV </p>
  
  <pre><code>   SecureRandom random = new SecureRandom();
     IvParameterSpec iv = new IvParameterSpec(random.generateSeed(16));
  </code></pre>
  
  <p>I am saving the IV and the AES Key in a file in a disk unencrypted. How do I now decrypt data using these two parameters using <code>openssl</code>?</p>