Does python have an equivalent to Javascript's 'btoa'
<p>I'm trying to find an exact equivalent to javascript's function 'btoa', as I want to encode a password as base64. It appears that there are many options however, as listed here: </p>

<p><a href="https://docs.python.org/3.4/library/base64.html" rel="nofollow">https://docs.python.org/3.4/library/base64.html</a></p>

<p>Is there an exact equivalent to 'btoa' in python? </p>

<p>Python's <a href="https://docs.python.org/3.4/library/base64.html" rel="nofollow">Base64</a>:</p>

<pre><code>import base64

encoded = base64.b64encode('Hello World!')
print encoded

# value of encoded is SGVsbG8gV29ybGQh
</code></pre>

<p>Javascript's <a href="http://www.w3schools.com/jsref/met_win_btoa.asp" rel="nofollow">btoa</a>:</p>

<pre><code>var str = "Hello World!";
var enc = window.btoa(str);

var res = enc;

// value of res is SGVsbG8gV29ybGQh
</code></pre>

<p>As you can see they both produce the same result.</p>

python base64