js

作者: LCSan | 来源:发表于2023-04-13 16:09 被阅读0次
//字符串转base64
function getEncode64(str) {
    return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function toSolidBytes(match, p1) {
        return String.fromCharCode('0x' + p1);
    }));
}
function getDecode(str) {
    return decodeURIComponent(atob(str).split('').map(function (c) {
        return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
    }).join(''));
}

相关文章

网友评论

      本文标题:js

      本文链接:https://www.haomeiwen.com/subject/jxnaddtx.html