title: Nodejs decrypt using crypto error wrong final block length
body: <p>I use this code to crypt/decrypt string value</p>
  
  <pre><code>var crypto = require('crypto');
  
  function encrypt(text){
      var cipher = crypto.createCipher('aes-256-cbc','secret key');
      var encrypted = cipher.update(text.toString(),'utf8','hex') + cipher.final('hex');
      return encrypted;
  }
  
  function decrypt(text){
      var decipher = crypto.createDecipher('aes-256-cbc','secret key');
      var decrypted = decipher.update(text.toString(),'hex','utf8') + decipher.final('utf8');
      return decrypted ;
  }
  
  module.exports.encrypt = encrypt;
  module.exports.decrypt = decrypt;
  </code></pre>
  
  <p>When i try to decrypt something that isn't crypted for example decrypt('test') it throw me the following error  :</p>
  
  <pre><code>crypto.js:292
    var ret = this._binding.final();
                            ^
  TypeError: error:0606506D:digital envelope routines:EVP_DecryptFinal_ex:wrong final block length
      at Decipher.Cipher.final (crypto.js:292:27)
  </code></pre>
  
  <p>I tryed also to use buffers without sucess and couldn't find any solution over Internet.</p>
  
  <p>The real problem is I use this to decrypt cookie value. If a hacker creates a fake cookie with the value "test" it will crash my program.</p>