用代码实现把字符串转换成base64编码
Sunny-117 opened this issue · comments
Sunny commented
beary commented
function encode(str){
const encodestr = encodeURI(str);
const base64 = btoa(encodestr);
return base64;
}
Aurora commented
function strToBase64(str) {
str = encodeURI(str);
return btoa(str);
}
function base64ToStr(base64) {
base64 = atob(base64);
return decodeURI(base64);
}