http://xy.cjbang.com.cn:19527/fromPost.html?shareDara={“randomStr”:“9cf6d3dc-7460-48d7-8659-41ffbcb0cfce”,“sign”:“94e5ce2672c41b81481b60f4c82ea608”,“reqNo”:“ETC2021-09-16 10:29:46000000000001”,“notifyUrl”:“http://www.baidu.com/”,“version”:“01”,“channelId”:“001896518572C53”,“authId”:“17639108392”,“timestamp”:“20210916102946”}
function base64_encode(str) {
let chars = “ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/”;//64个基本的编码
let c1, c2, c3;
let len = str.length;//需编码字符串的长度
let i = 0;
let out = “”;//输出
while (i < len) {
//位数不足情况
c1 = str.charCodeAt(i++) & 0xff;
if (i == len) {//一个字节 没有数据用 = 补上
out += chars.charAt(c1 >> 2);
out += chars.charAt((c1 & 0x3) << 4);
out += “==”;
break;
}
c2 = str.charCodeAt(i++);
if (i == len) {//两个字节 没有数据用 = 补上
out += chars.charAt(c1 >> 2);
out += chars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
out += chars.charAt((c2 & 0xF) << 2);
out += “=”;
break;
}
//位数足的情况
c3 = str.charCodeAt(i++);
out += chars.charAt(c1 >> 2);
out += chars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
out += chars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6));
out += chars.charAt(c3 & 0x3F);
}
return out;
}