一般用于解码后端返回的加密字符串
function Encode64(str) {
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,
function toSolidBytes(match, p1) {
return String.fromCharCode('0x' + p1);
}));
}
function Decode64(str) {
return decodeURIComponent(atob(str).split('').map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
}
let Value = '2022-11-12'
let encodeValue
let decodeValue
encodeValue = Encode64(Value)
decodeValue = Decode64(encodeValue)
console.log('Value:', Value);
console.log('encodeValue:', encodeValue);
console.log('decodeValue:', decodeValue);