Skip to content

Instantly share code, notes, and snippets.

View emctague's full-sized avatar
🖥️
Probably Coding

Ethan McTague emctague

🖥️
Probably Coding
View GitHub Profile
@emctague
emctague / base64.js
Created July 23, 2017 23:54
base64 encode/decode for node and browser
// Simple Base64 encode/decode that works in node and the browser.
var base64 = {
encode: function (text) {
if (typeof btoa === 'function')
return btoa(text)
else
return new Buffer(text).toString('base64')
},
decode: function (text) {
if (typeof atob === 'function')