前端向后台传参加密解密方法

 // 解密
        b64DecodeUnicode(str) {
            return decodeURIComponent(Array.prototype.map.call(atob(str), function(c) {
                return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
            }).join(''))
        },
        // 加密
        b64EncodeUnicode(str) {
            return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function(match, p1) {
                return String.fromCharCode(parseInt(p1, 16))
            }))
        },
posted @ 2020-04-03 10:54  诺克萨斯小刀  阅读(2628)  评论(0编辑  收藏  举报