title: 3des encryption in Node.JS returning invalid IV length
body: <p>I'm quite new to Node and have run into an issue with the encryption object:</p>
  
  <pre><code>var des3_key = new Buffer("redacted", "base64"); // copied from key in chilk
  var des3_iv = new Buffer("alsoredacted", "base64"); // copied from iv in chilk
  var des3_encryption = crypto.createCipheriv("des3", des3_key, des3_iv);
  // encode a string
  var string_to_encode = "thisisatest";
  var ciphered_string = des3_encryption.update(string_to_encode, "utf8", "base64");
  console.log(string_to_encode+" "+ciphered_string);
  </code></pre>
  
  <p>Both in the Node console and when running on the server, line 6 causes an error <code>node-crypto: Invalid IV length 32</code> instead of returning an encryption object, as expected.</p>
  
  <p>The key and IV I've removed and their encryption types are copied from another file but for the sake of testing I have tried various strings and encryption types but still get the same error, though with different lengths in the error.</p>
  
  <p>My knowledge of encryption is limited to what I've used previously and not much else unfortunately, and I'm having trouble finding troubleshooting resources for Node in this regard. Any help would be appreciated.</p>
  
  <p>Edit: Experimenting with des and des3 yields the same result.</p>