title: Node.js crypto key and iv to match java SecretKeySpec / IvParameterSpec
body: <p>I'm trying to to port a Java (simple) encryption algorythm to Node JS. I will need to be able to decrypt/encrypt stuff encrypted/decrypted from the Java side.</p>
  
  <p>I'm stuck at the very beginning, the initialization of the cipher.</p>
  
  <p>In Java, I get the key with <code>SecretKeySpec</code>, and the Initialization Vector with <code>IvParameterSpec</code>:</p>
  
  <pre><code>public CryptStuff(String password) throws zillion_exceptions {
      if (password==null) throw new InvalidKeyException("No encryption password is set!");
      key = new SecretKeySpec(password.getBytes("UTF-8"), "AES");
      cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
      ivSpec=new IvParameterSpec(new byte[cipher.getBlockSize()]);
      cipher.init(Cipher.ENCRYPT_MODE, key, ivSpec);
  }
  </code></pre>
  
  <p>NodeJS requires a Key Buffer and an IV buffer, however, I don't know how to calculate them from scratch:</p>
  
  <pre><code>var mCrypto = require('crypto'),
      key=[0,0,0,0,0,0,.......],
      iv=[0,0,0,0,0,.........];
  
  function init (password) {
  
      // generate key from password
      // generate IV from blocksize?
  
      var aesCipher = mCrypto.createCipheriv("aes-????????", (new Buffer(key)), (new Buffer(iv)));
      .
      .
      .
  }
  </code></pre>
  
  <p>Also, what's the matching algorithm string for AES/CBC/PKCS5Padding? </p>