Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

用代码实现把字符串转换成base64编码 #266

Open
Sunny-117 opened this issue Nov 4, 2022 · 2 comments
Open

用代码实现把字符串转换成base64编码 #266

Sunny-117 opened this issue Nov 4, 2022 · 2 comments

Comments

@Sunny-117
Copy link
Owner

No description provided.

@bearki99
Copy link

function encode(str){
    const encodestr = encodeURI(str);
    const base64 = btoa(encodestr);
    return base64;
}

@gswysy
Copy link

gswysy commented Mar 10, 2024

function strToBase64(str) {
      str = encodeURI(str);
      return btoa(str);
}
function base64ToStr(base64) {
      base64 = atob(base64);
      return decodeURI(base64);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants