title: Base64 encoding of String in Node.js
body: <p>I try to encode a string in both browser and server but I have different base64 encoding for a specific string</p>
  
  <p>Here is my string: "£aº©S=³hPó c¨¸" (Hexa: 00a3006100ba00a900940053003d00b30068005000f300900020006300a800b8 )</p>
  
  <p>Client-side: I encode this String using btoa() and I have : <code>o2G6qZRTPbNoUPOQIGOouA==</code> and this is the result I expect.</p>
  
  <p>Server-side: I code this String using Buffer according to <a href="https://stackoverflow.com/questions/6182315/how-to-do-base64-encoding-in-node-js">this answer</a> in Node.js i have :</p>
  
  <pre><code>var ciphertext = ... // myString
  console.log(ciphertext.hexEncode()); // 00a3006100ba00a900940053003d00b30068005000f300900020006300a800b8  
  console.log(Buffer.from(ciphertext, 'utf8').toString('base64')) // wqNhwrrCqcKUUz3Cs2hQw7PCkCBjwqjCuA==
  console.log(Buffer.from(ciphertext, 'ucs2').toString('base64')) // owBhALoAqQCUAFMAPQCzAGgAUADzAJAAIABjAKgAuAA=
  </code></pre>