Created
January 11, 2019 09:29
-
-
Save niceaji/d491cea308696890a5e520b4c42df39b 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
| export function b64EncodeUnicode(str) { | |
| return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function(match, p1) { | |
| return String.fromCharCode(parseInt(p1, 16)) | |
| })) | |
| } | |
| export function b64DecodeUnicode(str) { | |
| return decodeURIComponent(Array.prototype.map.call(atob(str), function(c) { | |
| return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2) | |
| }).join('')) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment