title: Convert Java code to NodeJS - Encryption method
body: <p>I want to duplicate the JAVA encryption code in NodeJS.</p>
  
  <pre><code>private String DEFAULT_KEY = "abcdwAYserXbzcSeqL/zPg==";
  private String text = "abc";
  Base64 base64decoder = new Base64();
  byte[] raw = base64decoder.decode(key);
  
  SecretKeySpec fSecretKeySpec = new SecretKeySpec(raw, "AES");
  
  Cipher cipher = Cipher.getInstance("AES");
  cipher.init(Cipher.ENCRYPT_MODE, fSecretKeySpec);
  byte[] encrypted = cipher.doFinal(text.getBytes());
  
  Base64 base64encoder = new Base64();
  result = base64encoder.encodeToString(encrypted);
  System.out.println("result: "+ result);
  </code></pre>
  
  <p>The above code generate the encrypted code as: <code>ZkojvMTW+9EEK0owxMuA7A==</code></p>
  
  <p>I have tried few ways in NodeJS. It is not generating same code for me.</p>
  
  <p>I have tried the following code.</p>
  
  <pre><code>var bKey = new Buffer('abcdwAYserXbzcSeqL/zPg==', 'base64');
  var cipher = crypto.createCipher('aes-128-ecb',bKey);
  //cipher.setAutoPadding(auto_padding=false);
  var crypted = cipher.update('abc',null,'base64');
  crypted+=cipher.final('base64');
  console.log(crypted);
  </code></pre>
  
  <p>Can someone help me out?</p>