node.js base64

来源:互联网 发布:淘宝捉猫猫是什么 编辑:程序博客网 时间:2024/05/01 22:23

1、图片转base64

var fs = require("fs");

var imageBuf = fs.readFileSync("D:\\Documents\\Desktop\\logo.gif");

console.log(imageBuf.toString("base64"));

 

2、转base64

var a= newBuffer('key1=value1&key2=value2').toString('base64');

 

undefined> a'a2V5MT12YWx1ZTEma2V5Mj12YWx1ZTI='>

 

3、base64转字符串

 

newBuffer(a,'base64').toString()

 

'key1=value1&key2=value2'

0 0
原创粉丝点击