title: CryptoJS DES in ECB mode
body: <p>I'm dealing with a third-party gateway that requires DES ECB with PKCS1 padding. So this code is not for my own use, but to send the message to the other guys.</p>
  
  <p>Before you ask how come they're using symmetrical-key encryption on the internet: I first must send  them symmetrical key encrypted with SHA algorithm and only then encode the message with the DES key.
  This is NOT MY IDEA doing it. But it's very important for my project etc.</p>
  
  <p>I will do my own padding function, so please don't point me on NoPadding option. This code is just to test if DES works fine on my side.</p>
  
  <p>I'm facing a weird (for me) behavior of the crypt-js module in node.js
  Here's the code:</p>
  
  <pre><code>var C = require('crypto-js'),
      source = 'abcdefghabcdefgh',
      key = '1234test';
  
  var encrypted = C.DES.encrypt(
      C.enc.Utf8.parse(source),
      C.enc.Hex.parse(key),
      { mode: C.mode.ECB, padding: C.pad.NoPadding }
  ).ciphertext.toString();
  
  var decrypted = C.DES.decrypt(
      C.lib.CipherParams.create({ ciphertext: C.enc.Utf8.parse(encrypted) }),
      C.enc.Hex.parse(key),
      { mode: C.mode.ECB, padding: C.pad.NoPadding }
  ).toString();
  
  if (source === decrypted) {
      console.log('Glad :)');
  } else {
      console.log('Sad :(');
  }
  </code></pre>
  
  <p>The code won't turn glad this way.
  Crypto-JS and all other modules are the latest versions.
  Can someone please explain this to me?</p>