title: Heroku production server encryption and local decryption fail
body: <p>I am encrypting some text with the following <code>encrypt</code> function on Heroku:</p>
  
  <pre><code>const crypto = require('crypto');
  
  // function to encrypt data ....
  function encrypt(KEY, text){
    const cipher = crypto.createCipher('aes192', KEY);
    var encrypted = cipher.update(text,'utf8', 'hex');
    encrypted += cipher.final('hex');
    return encrypted;
  }
  
  // function to decryt data..............
  function decrypt(KEY, text){ 
      const decipher = crypto.createDecipher('aes192', KEY) 
      var decrypted = decipher.update(text,'hex','utf8') 
      decrypted += decipher.final('utf8'); 
      return decrypted; 
   }
  </code></pre>
  
  <p>It then saves the text I encrypted to MongoDb server. I read the encrypted value and try to decrypt it on the local machine, but get a <code>digital envelope routines:EVP_DecryptFinal_ex:bad decrypt</code>. I have spent so much time trying to figure out what is the issue.</p>
  
  <p>Both in Heroku and locally I am using the same key. If I try this code locally (i.e. encrypt and decrypt locally), then everything works as expected.</p>
  
  <p>Do you have an idea of what might be going wrong?</p>
  
  <p>I have noticed that heroku server is in United States, while I am in UK. Does the timezone play any role in here?</p>