title: base64 encode binary string returns different values in NodeJS and Python
body: <p>I am trying to base64 encode a binary string in NodeJS and python and I'm getting 2 different values.</p>
  
  <p>Note that the value is <code>i</code> is 16 random bytes generated in python using <code>os.urandom(16)</code></p>
  
  <p>NodeJS</p>
  
  <pre class="lang-js prettyprint-override"><code>&gt; var i = '&gt;e\x93\x10\xabK\xbe\xfeX\x97\x9a$\r\xef\x8f3';
  &gt; var s = new Buffer(i).toString('base64');
  &gt; console.log(s);
  PmXCkxDCq0vCvsO+WMKXwpokDcOvwo8z
  </code></pre>
  
  <p>Python</p>
  
  <pre class="lang-py prettyprint-override"><code>&gt;&gt;&gt; import base64
  &gt;&gt;&gt; i = '&gt;e\x93\x10\xabK\xbe\xfeX\x97\x9a$\r\xef\x8f3'
  &gt;&gt;&gt; s = base64.b64encode(i)
  &gt;&gt;&gt; print s
  PmWTEKtLvv5Yl5okDe+PMw==
  </code></pre>
  
  <p>Am I doing something wrong? It does work for regular string such as my name.</p>
  
  <p>NodeJS</p>
  
  <pre class="lang-js prettyprint-override"><code>&gt; var s = new Buffer('travis').toString('base64');
  undefined
  &gt; console.log(s);
  dHJhdmlz
  </code></pre>
  
  <p>Python</p>
  
  <pre class="lang-py prettyprint-override"><code>&gt;&gt;&gt; s = base64.b64encode('travis')
  &gt;&gt;&gt; print s
  dHJhdmlz
  </code></pre>