base64 인코딩, 디코딩 해야될 때가 있다.
이때 쓰면 편리한 것이다.
function b64DecodeUnicode(str) {
return decodeURIComponent(atob(str).split('').map(function(c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
}
let char = "SEVMTE8gV09STEQh";
b64DecodeUnicode(char);
// >>> HELLO WORLD!
// base64 인코드 메소드 -> window.btoa()
let incodeChar;
incodeChar = window.btoa('targetChar');
// >>> dGFyZ2V0Q2hhcg==
// base64 디코드 메소드 -> window.atob()
let decodeChar;
decodeChar = window.atob(incodeChar);
// >>> targetChar
'Javascript' 카테고리의 다른 글
배열의 중복값 제거 (0) | 2019.04.25 |
---|---|
[자료구조] (0) | 2019.04.25 |
다수의 엘리먼트에 이벤트 등록하기 (0) | 2019.04.11 |
[Object] Object 다루기 - map, filter 로 값 추출하기 (0) | 2019.04.11 |
Promise Chain 구성하기 (0) | 2019.04.11 |