| 
									
										
										
										
											2012-09-19 14:22:55 -06:00
										 |  |  | btoa | 
					
						
							|  |  |  | === | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-25 10:01:20 -07:00
										 |  |  | A port of the browser's `btoa` function. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-19 14:22:55 -06:00
										 |  |  | Uses `Buffer` to emulate the exact functionality of the browser's btoa (except that it supports unicode and the browser may not). | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-20 09:58:09 -05:00
										 |  |  | It turns <strong>b</strong>inary data __to__ base64-encoded <strong>a</strong>scii. | 
					
						
							| 
									
										
										
										
											2012-09-19 14:22:55 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  |     (function () { | 
					
						
							|  |  |  |       "use strict"; | 
					
						
							|  |  |  |        | 
					
						
							|  |  |  |       var btoa = require('btoa') | 
					
						
							|  |  |  |         , bin = "Hello, 世界" | 
					
						
							|  |  |  |         , b64 = btoa(bin) | 
					
						
							|  |  |  |         ; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       console.log(b64); // "SGVsbG8sIBZM" | 
					
						
							|  |  |  |     }()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Note: Unicode may or may not be handled incorrectly. | 
					
						
							| 
									
										
										
										
											2014-05-20 08:55:05 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | Copyright and license | 
					
						
							|  |  |  | === | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Code and documentation copyright 2012-2014 AJ ONeal Tech, LLC. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Code released under the [Apache license](https://github.com/node-browser-compat/btoa/blob/master/LICENSE). | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Docs released under [Creative Commons](https://github.com/node-browser-compat/btoa/blob/master/LICENSE.DOCS). |