From the comments (by SET and Stefan Steiger) below the accepted answer, here is a quick summary of how to encode/decode a string to/from base64 without need of a library.
str = "The quick brown fox jumps over the lazy dog";
b64 = btoa(unescape(encodeURIComponent(str)));
str = decodeURIComponent(escape(window.atob(b64)));
(uses jQuery library, but not for encode/decode)
str = "The quick brown fox jumps over the lazy dog";_x000D_
_x000D_
$('input').val(str);_x000D_
_x000D_
$('#btnConv').click(function(){_x000D_
var txt = $('input').val();_x000D_
var b64 = btoa(unescape(encodeURIComponent(txt)));_x000D_
$('input').val(b64);_x000D_
$('#btnDeConv').show();_x000D_
});_x000D_
$('#btnDeConv').click(function(){_x000D_
var b64 = $('input').val();_x000D_
var txt = decodeURIComponent(escape(window.atob(b64)));_x000D_
$('input').val(txt);_x000D_
});
_x000D_
#btnDeConv{display:none;}
_x000D_
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>_x000D_
_x000D_
<input type="text" />_x000D_
<button id="btnConv">Convert</button>_x000D_
<button id="btnDeConv">DeConvert</button>
_x000D_