title: Hex to String & String to Hex conversion in nodejs
body: <p>I need to convert data into String to Hex and then again from Hex to String using nodejs 8</p>
  
  <p>I have issue while decoding from Hex to String</p>
  
  <p><strong>Code to convert <code>string into hex</code></strong></p>
  
  <pre><code>function stringToHex(str)
  {
      const buf = Buffer.from(str, 'utf8');
      return buf.toString('hex');
  }
  </code></pre>
  
  <p><strong>Code to convert <code>hex into string</code></strong></p>
  
  <pre><code>function hexToString(str)
  {
      const buf = new Buffer(str, 'hex');
      return buf.toString('utf8');
  }
  </code></pre>
  
  <p>I have string <code>dailyfile.host</code></p>
  
  <p>output of <strong>encoding</strong>: <code>3162316637526b62784a5a37697a45796c656d465643747a4a505a6f59774641534c75714733544b4446553d</code></p>
  
  <p>output of <strong>decoding</strong>: <code>1b1f7RkbxJZ7izEylemFVCtzJPZoYwFASLuqG3TKDFU=</code></p>
  
  <p><strong>Required</strong> output of decoding: <code>dailyfile.host</code></p>