Updated & refreshed content:
Updated & refreshed content:
Updated & refreshed content:
.gp-tool-block { max-width:100%; box-sizing:border-box; }
.gp-tool-inner { –gp-bg: rgb(28,36,75); –gp-accent: rgb(254,200,12); –gp-text: #ffffff; –gp-accent-text: rgb(47,54,69); background: var(–gp-bg); color: var(–gp-text); padding:18px; border-radius:10px; font-family: inherit; }
.gp-tool-inner h2 { margin:0 0 12px 0; color: var(–gp-accent); text-align:center; font-size:1.25rem; }
.gp-row { display:flex; gap:10px; align-items:center; margin-bottom:10px; }
.gp-label { display:block; margin-bottom:6px; color:var(–gp-accent); font-weight:600; }
#gpMode { padding:8px 10px; border-radius:6px; border:none; background: rgba(255,255,255,0.03); color:inherit; }
#gpInput { width:100%; padding:10px; border-radius:6px; border:none; box-sizing:border-box; background: rgba(255,255,255,0.03); color:inherit; font-family: inherit; font-size:15px; resize:vertical; }
#gpPass { width:100%; padding:10px; border-radius:6px; border:none; box-sizing:border-box; background: rgba(255,255,255,0.03); color:inherit; font-size:15px; }
#gpOutputWrap { margin-top:14px; display:none; }
.gp-output-label { display:block; margin-bottom:6px; color:var(–gp-accent); font-weight:600; }
#gpOutput { background: rgba(0,0,0,0.15); padding:12px; border-radius:6px; white-space:pre-wrap; word-break:break-word; min-height:60px; }
.gp-tool-actions { margin-top:10px; text-align:right; }
#gpCopyBtn { background: var(–gp-accent); color: var(–gp-accent-text); border: none; padding: 8px 12px; border-radius: 6px; cursor: pointer; font-weight: 700; }
.gp-note { margin-top:12px; font-size:13px; color: #cfd6ff; opacity:0.9; }
@media (max-width:480px){ .gp-tool-inner { padding:14px; } }
(function(){
const TOOL_NAME = ‘AES Encryption Tool’;
const TRACK_ON_FIRST_INTERACTION = true;
// Scoped root element
const root = document.currentScript ? document.currentScript.parentElement : document.getElementsByClassName(‘gp-tool-block’)[0];
const modeEl = root.querySelector(‘#gpMode’);
const inputEl = root.querySelector(‘#gpInput’);
const passEl = root.querySelector(‘#gpPass’);
const outputWrap = root.querySelector(‘#gpOutputWrap’);
const outputEl = root.querySelector(‘#gpOutput’);
const copyBtn = root.querySelector(‘#gpCopyBtn’);
// Utilities: encode/decode helpers
function bufToBase64(buf){
const bytes = new Uint8Array(buf);
let binary = ”;
for (let i=0;i<bytes.byteLength;i++) binary += String.fromCharCode(bytes[i]);
return btoa(binary);
}
function base64ToBuf(b64){
const binary = atob(b64);
const len = binary.length;
const bytes = new Uint8Array(len);
for (let i=0;i returns Base64 string containing salt + iv + ciphertext
async function encryptText(plain, passphrase){
const enc = new TextEncoder();
const salt = crypto.getRandomValues(new Uint8Array(16));
const iv = crypto.getRandomValues(new Uint8Array(12));
const key = await deriveKey(passphrase, salt);
const cipherBuf = await crypto.subtle.encrypt({ name: ‘AES-GCM’, iv: iv }, key, enc.encode(plain));
// concat salt|iv|cipher
const combined = new Uint8Array(salt.byteLength + iv.byteLength + cipherBuf.byteLength);
combined.set(salt, 0);
combined.set(iv, salt.byteLength);
combined.set(new Uint8Array(cipherBuf), salt.byteLength + iv.byteLength);
return bufToBase64(combined.buffer);
}
// Decrypt from Base64 token (expects salt|iv|cipher)
async function decryptText(tokenB64, passphrase){
const combinedBuf = base64ToBuf(tokenB64);
const combined = new Uint8Array(combinedBuf);
if (combined.length copyBtn.textContent = prev, 1200);
}).catch(function(){
// fallback
const range = document.createRange(); range.selectNodeContents(outputEl);
const sel = window.getSelection(); sel.removeAllRanges(); sel.addRange(range);
try{ document.execCommand(‘copy’); }catch(e){}
sel.removeAllRanges();
});
});
// Event listeners: live updates and tracking on first focus/click
[modeEl, inputEl, passEl].forEach(el => {
el.addEventListener(‘input’, update);
el.addEventListener(‘focus’, trackInteraction, { once: true });
el.addEventListener(‘click’, trackInteraction, { once: true });
});
// Initialize placeholder
update();
// Prevent unhandled promise rejections from halting scripts
window.addEventListener(‘unhandledrejection’, function(e){
// swallow to avoid noisy console errors on older browsers; keep silent
e.preventDefault();
});
})();
Check out latest updates & share!
Check out latest updates & share!
Check out latest updates & share!