title: Using Java to decrypt openssl aes-256-cbc using provided key and iv
body: <p>I have been searching for a Java code example to do the following but have been unsuccessful.  I'm looking for a solution for my particular situation.</p>
  
  <p>A key and IV have been generated using "testtest" for a password:</p>
  
  <pre><code>openssl enc -aes-256-cbc -P 
  salt=2855243412E30BD7
  key=E4A38479A2349177EAE6038A018483318350E7F5430BDC8F82F1974715CB54E5
  iv=629E2E1500B6BA687A385D410D5B08E3
  </code></pre>
  
  <p>A file(named text) has been encrypted on Linux using openssl command:</p>
  
  <pre><code>openssl enc -aes-256-cbc -K 
  E4A38479A2349177EAE6038A018483318350E7F5430BDC8F82F1974715CB54E5 -iv
  629E2E1500B6BA687A385D410D5B08E3 -e -in text -out text_ENCRYPTED
  </code></pre>
  
  <p>It can be decrypted successfully using:</p>
  
  <pre><code>openssl enc -aes-256-cbc -K 
  E4A38479A2349177EAE6038A018483318350E7F5430BDC8F82F1974715CB54E5 -iv 
  629E2E1500B6BA687A385D410D5B08E3 -d -in text_ENCRYPTED -out text_DECRYPTED
  </code></pre>
  
  <p>I have access to the encrypted file, the salt, the key and the iv.  I do not believe I'm going to receive the password.  Also, i have installed the unlimited strength JCE policy.  So far I have only found examples where another java program does the encryption and generates these parameters.  For my case I must use the salt, key and iv values given to me to decrypt a file.  Is this possible with Java?  Please remember I'm bound by this configuration, thank you very much for your time and help.</p>