🔐 PSK Generator (256-bit)
Key Strength:
Not generated
function generateKey() {
const bytes = new Uint8Array(32);
crypto.getRandomValues(bytes);
const hex = Array.from(bytes)
.map(b => b.toString(16).padStart(2, ‘0’))
.join(”);
const base64 = btoa(String.fromCharCode(…bytes));
document.getElementById(“hexKey”).value = hex;
document.getElementById(“base64Key”).value = base64;
updateStrength();
}
function copyText(id) {
const el = document.getElementById(id);
el.select();
document.execCommand(“copy”);
alert(“Copied!”);
}
function updateStrength() {
const bar = document.getElementById(“strengthBar”);
const text = document.getElementById(“strengthText”);
bar.style.width = “100%”;
bar.style.background = “limegreen”;
text.innerText = “Very Strong (256-bit secure)”;
}
function downloadKey() {
const hex = document.getElementById(“hexKey”).value;
const base64 = document.getElementById(“base64Key”).value;
const blob = new Blob(
[`HEX:\n${hex}\n\nBASE64:\n${base64}`],
{ type: “text/plain” }
);
const a = document.createElement(“a”);
a.href = URL.createObjectURL(blob);
a.download = “psk-key.txt”;
a.click();
}
function toggleTheme() {
document.body.classList.toggle(“light”);
}