title: Encrypt a string in nodejs and decrypt in java
body: <p>I am encrypting a text in NODEJS and trying decrypt in Java but getting error.
  my nodejs code:</p>
  
  <pre><code>var crypto = require('crypto')
    , key = 'mykey@91'
    , plaintext = 'SS18617710213463'
    , cipher = crypto.createCipher('aes-128-ecb', key)
    , decipher = crypto.createDecipher('aes-128-ecb', key);
  
  
  
  var encryptedPassword = cipher.update(plaintext, 'utf8', 'base64');
  
  encryptedPassword += cipher.final('base64')
  
  var decryptedPassword = decipher.update(encryptedPassword, 'base64', 'utf8');
  decryptedPassword += decipher.final('utf8');
  
  console.log('original  :', plaintext); 
  console.log('encrypted :', encryptedPassword);
  console.log('decrypted :', decryptedPassword);
  </code></pre>
  
  <p>but when I am trying to decrypt it, it always throws an error.</p>
  
  <pre><code>public static String decrypt(String encryptedText) {
      try {
           final String key = "mykey@91";
          Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
          SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(), "AES");
          cipher.init(Cipher.DECRYPT_MODE, secretKey);
          byte[] cipherText = Base64.getDecoder().decode(encryptedText.getBytes("UTF8"));
          String decryptedString = new String(cipher.doFinal(cipherText),"UTF8");
          return decryptedString;
      } catch (Exception e) {
          e.printStackTrace();
      }
      return null;
  }
  </code></pre>
  
  <p>The error I am getting as below:</p>
  
  <blockquote>
    <p>java.security.InvalidKeyException: Invalid AES key length: 8 bytes</p>
  </blockquote>