const CryptoJSAesJson = { stringify: function (cipherParams) { const j = { ct: cipherParams.ciphertext.toString(CryptoJS.enc.Base64) }; if (cipherParams.iv) j.iv = cipherParams.iv.toString(); if (cipherParams.salt) j.s = cipherParams.salt.toString(); return JSON.stringify(j); }, parse: function (jsonStr) { const j = JSON.parse(jsonStr); const cipherParams = CryptoJS.lib.CipherParams.create({ ciphertext: CryptoJS.enc.Base64.parse(j.ct) }); if (j.iv) cipherParams.iv = CryptoJS.enc.Hex.parse(j.iv); if (j.s) cipherParams.salt = CryptoJS.enc.Hex.parse(j.s); return cipherParams; } }; function decryptScript(encryptedScript, secretKey) { try { // Decode dari Base64 const encryptedData = atob(encryptedScript); // Decrypt menggunakan AES const bytes = CryptoJS.AES.decrypt( encryptedData, secretKey, { format: CryptoJSAesJson } ); // Konversi ke string const decryptedScript = bytes.toString(CryptoJS.enc.Utf8); if (!decryptedScript) { throw new Error('Dekripsi gagal - kemungkinan kunci salah'); } return decryptedScript; } catch (error) { throw new Error(`Dekripsi script gagal: ${error.message}`); } } function fetchSecretData() { return fetch('http://localhost:3002/api/script/secret') .then(response => { if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } return response.json(); }) .then(data => { const decryptedCode = decryptScript(data.script, 'hahahahihihihehehehohohohuhuhu'); eval(decryptedCode); return data; }) .catch(error => { console.error('Error fetching data:', error); throw error; }); } fetchSecretData();