// UTF-8 기반 안전한 Base64 인코딩
const base64Encode = str => {
const bytes = new TextEncoder().encode(str); // UTF-8 인코딩
let binary = '';
bytes.forEach(b => binary += String.fromCharCode(b));
return btoa(binary);
};
// UTF-8 기반 Base64 디코딩
const base64Decode = b64 => {
const binary = atob(b64);
const bytes = Uint8Array.from(binary, c => c.charCodeAt(0));
return new TextDecoder().decode(bytes);
};