UNPKG

982 BMarkdownView Raw
1btoa
2===
3
4| [atob](https://git.coolaj86.com/coolaj86/atob.js)
5| **btoa**
6| [unibabel.js](https://git.coolaj86.com/coolaj86/unibabel.js)
7| Sponsored by [ppl](https://ppl.family)
8
9A port of the browser's `btoa` function.
10
11Uses `Buffer` to emulate the exact functionality of the browser's btoa
12(except that it supports some unicode that the browser may not).
13
14It turns <strong>b</strong>inary data __to__ base64-encoded <strong>a</strong>scii.
15
16```js
17(function () {
18 "use strict";
19
20 var btoa = require('btoa');
21 var bin = "Hello, 世界";
22 var b64 = btoa(bin);
23
24 console.log(b64); // "SGVsbG8sIBZM"
25}());
26```
27
28**Note**: Unicode may or may not be handled incorrectly.
29This module is intended to provide exact compatibility with the browser.
30
31Copyright and License
32===
33
34Code copyright 2012-2018 AJ ONeal
35
36Dual-licensed MIT and Apache-2.0
37
38Docs copyright 2012-2018 AJ ONeal
39
40Docs released under [Creative Commons](https://git.coolaj86.com/coolaj86/btoa.js/blob/master/LICENSE.DOCS).