mishe / blog

前端碰上的问题或体会
230 stars 39 forks source link

字符串加密(转换成图片的base64码) #91

Open mishe opened 8 years ago

mishe commented 8 years ago

字符串加密(转换成图片的base64码)

本方案的基础是需要浏览器支持canvas。

使用方法

转换为图片

var str=JSON.stringify({a:'中文',b:'sss'}),
    str2=compressor.compress(str)
    console.log(str2)

还原字符串

compressor.decompressImage(str2,function(d){
    console.log(JSON.parse(d).a)
})