title: Base64 encode a string in Cloud Code
body: <p>How do I base64 encode a string in cloud code? The value is for a HTTP Basic Auth.</p>
  
  <p>I have tried the following two approaches and I had no success.</p>
  
  <pre><code>var string = 'AQXTTPmj-boT_yDEPQXg9ezIOIM7O:EMx6RLr8jF3S6YYo-X4bZ';
  var buffer1 = new Buffer(string, 'base64');
  var b3 = buffer1.toString('base64');
  console.log(b3);
  </code></pre>
  
  <hr>
  
  <pre><code>var string = 'AQXTTPmj-boT_yDEPQXg9ezIOIM7O:EMx6RLr8jF3S6YYo-X4bZ';
  var encodeString = Base64.encode(string);
  console.log(encodeString);
  </code></pre>