Created
February 19, 2022 12:23
-
-
Save ZakharDay/f19d65a9aa7863ee6720f02460c8e961 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let text = "поздравляю со сдачей сессии" | |
let encoded = btoa(text) | |
let decoded = atob(encoded) | |
function utf8_to_b64( str ) { | |
return window.btoa(unescape(encodeURIComponent( str ))); | |
} | |
function b64_to_utf8( str ) { | |
return decodeURIComponent(escape(window.atob( str ))); | |
} | |
encoded = utf8_to_b64(text) | |
let urlSafeEncoded = encoded.replaceAll('/', '_').replaceAll('+', '-') | |
let urlSafeDecoded = urlSafeEncoded.replaceAll('_', '/').replaceAll('-', '+') | |
decoded = b64_to_utf8(urlSafeDecoded) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment