//base64加密
var plainText = "你好,世界!";
//如果含有特殊字符,中文要先进行编码
var utf8Text = encodeURIComponent(plainText);
//加密
var encodedText = btoa(utf8Text);
//解密后进行解码
console.log(atob(encodedText)); // 输出:JUU0JUJEJUEwJUU1JUEwJUIxJUU1JThCJUIwJUU1JUJEJUI2JUU2JTgwJTg2
decodeURIComponent(atob(encodedText))//解码
js base64加密
最新推荐文章于 2024-05-09 19:38:25 发布