title: CBC with AES : Encrypting in Perl and Decrypting in Java
body: <p>I am encrypting a file in perl and want to decrypt in java. here is my encryption code:</p>
  
  <p>== Encryption in Perl ==</p>
  
  <pre><code>$key = "1234567890123456";
  $plain_text = "this is foo";
  open ($fh, "&gt;" . $output_file_path) || die ("open ($output_file_path):$!");
  my $cipher = Crypt::CBC-&gt;new( -key =&gt; $key, -cipher =&gt; "Crypt::OpenSSL::AES");
  $cipher-&gt;start("");
  print $fh $cipher-&gt;crypt($plain_text);
  </code></pre>
  
  <p>And this is the decryption code I am using, but it is not working.</p>
  
  <p>== Decryption in Java ==</p>
  
  <pre><code>String key = "1234567890123456";
  byte[] encrypted_bytes = READ_DATA_FROM_FILE
  SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes(), "AES");
  IvParameterSpec ivSpec = new IvParameterSpec(key.getBytes());
  Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
  cipher.init(Cipher.DECRYPT_MODE, skeySpec, ivSpec);
  String plain_text = new String(cipher.doFinal(encrypted_bytes));
  </code></pre>
  
  <p>Can someone help me in this?</p>