您的位置:首页 > Web前端 > Node.js

使用ES6语法进行Base64的编码和解码

2017-12-08 01:09 726 查看

ES6: base64解码

/**
* ES6: base64解码
*/
decodeBase64Content: function (base64Content) {
let commonContent = base64Content.replace(/\s/g, '+');
commonContent = Buffer.from(commonContent, 'base64').toString();
return commonContent;
}


ES6: base64编码

/**
* ES6: base64编码
*/
encodeBase64Content: function (commonContent) {
let base64Content = Buffer.from(commonContent).toString('base64');
return base64Content;
},
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  base64 编码 node-js