title: Node JS crypto "Bad input string"
body: <p>Want to decrypt a string from file.</p>
  
  <p>But when i use nodejs decipher on the string from fs, it gives the error "Bad input string"</p>
  
  <pre><code>var fs = require('fs');
  var crypto = require('crypto');
  
  function decrypt(text){
    var decipher = crypto.createDecipher('aes-256-ctr', 'password')
    var dec = decipher.update(text,'hex','utf8')
    dec += decipher.final('utf8');
    return dec;
  }
  
  fs.readFile('./file.json', 'utf8', function (err,data) {
    if (err) return console.log(err);
    console.log(decrypt(data));
  });
  </code></pre>
  
  <p>tried just making a string like this it works</p>
  
  <pre><code>var stringInFile= "encryptedString";
  console.log(decrypt(stringInFile));
  </code></pre>
  
  <p>Tho 
  console.log(data)  from fs also gives 'encryptedString'</p>