code: function encrypt(obj) {
      var json = JSON.stringify(obj);
  
      // First generate a random IV.
      // AES-256 IV size is sixteen bytes:
      var iv = crypto.randomBytes(16);
  
      // Make sure to use the 'iv' variant when creating the cipher object:
      var cipher = crypto.createCipheriv('aes-256-cbc', cryptoKey, iv);
  
      // Generate the encrypted json:
      var encryptedJson = cipher.update(json, 'utf8', 'base64') + cipher.final('base64');
  
      // Include the hex-encoded IV + the encrypted base64 data
      // NOTE: We're using hex for encoding the IV to ensure that it's of constant length.
      var result = iv.toString('hex') + encryptedJson;
  
      if( verifyHmac ) {
        // Prepend an HMAC to the result to verify it's integrity prior to decrypting.
        // NOTE: We're using hex for encoding the hmac to ensure that it's of constant length
        result = hmac(result, 'hex') + result;
      }
  
      return result;
    }
docs: Encrypts an arbitrary object using the derived cryptoKey and retursn the result as text. The object is first serialized to JSON (via JSON.stringify) and the result is encrypted.  The format of the output is: [<hmac>]<iv><encryptedJson>  <hmac>             : Optional HMAC <iv>               : Randomly generated initailization vector <encryptedJson>    : The encrypted object