node.js使用buffer实现base64编解码

2017-04-27 18:04

nodejs使用buffer实现base64编解码

> var a = new Buffer('key1=value1&key2=value2').toString('base64');
undefined
> a
'a2V5MT12YWx1ZTEma2V5Mj12YWx1ZTI='
> new Buffer(a, 'base64').toString()
'key1=value1&key2=value2'