html前端的几种加密/解密方式
html前端的几种加密/解密方式一、base64加密
html前端的几种加密/解密方式
一、base64加密
前端用base64加密和解密的使用方法,只需要两个函数就可以了。一个是加密:window.btoa(),一个是解密:window.atob(),看例子:
varstr="hello";varstr64=window.btoa("hello");console.log("字符串是:"+str);console.log("经base64编码后:"+str64);console.log("base64解码后:"+window.atob(str64));