title: NodeJS: How do I get a correct encrypted result?
body: <p>I am writing the DES encryption code using NodeJS.</p>
  
  <p>According to the DES algorithm, the result should be like this,</p>
  
  <pre><code>* http://www.unsw.adfa.edu.au/~lpb/src/DEScalc/DEScalc.html
  
  An example DES test value, taken from
  "H. Katzan, The Standard Data Encryption Algorithm, pp75-94, Petrocelli Books Inc., New York, 1977" is:
  
  Key:        5B5A57676A56676E (HEX)
  Plaintext:  675A69675E5A6B5A (HEX)
  Ciphertext: 974AFFBF86022D1F (HEX)
  </code></pre>
  
  <p>However, my code prints somewhat different values.</p>
  
  <pre><code>var assert = require("assert");
  var crypto = require("crypto");
  
  var plaintext = new Buffer( '675A69675E5A6B5A', 'hex' ).toString( 'binary' );
  var key = new Buffer( '5B5A57676A56676E', 'hex' ).toString( 'binary' );
  
  var cipher = crypto.createCipher( 'des-ecb', key );
  var c = cipher.update( plaintext, 'binary', 'hex' );
  c += cipher.final( 'hex' );
  
  console.log( c );
  </code></pre>
  
  <p>What should I fix in the upper code?</p>