{"id":555,"date":"2026-07-20T14:46:26","date_gmt":"2026-07-20T14:46:26","guid":{"rendered":"https:\/\/freewebtools.co.in\/?page_id=555"},"modified":"2026-07-20T16:30:31","modified_gmt":"2026-07-20T16:30:31","slug":"password-encryption-and-decryption-tool","status":"publish","type":"page","link":"https:\/\/freewebtools.co.in\/index.php\/password-encryption-and-decryption-tool\/","title":{"rendered":"Password encryption and decryption tool"},"content":{"rendered":"\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <title>Password &#038; Text Encryption Tool<\/title>\n    <style>\n        :root {\n            --bg-color: #0d1117;\n            --card-bg: #161b22;\n            --accent: #58a6ff;\n            --text: #c9d1d9;\n            --error: #f85149;\n        }\n\n        body {\n            font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Helvetica, Arial, sans-serif;\n            background-color: var(--bg-color);\n            color: var(--text);\n            padding: 20px;\n            margin: 0;\n            display: flex;\n            flex-direction: column;\n            align-items: center;\n        }\n\n        .container {\n            display: grid;\n            grid-template-columns: 1fr 1fr;\n            gap: 20px;\n            max-width: 1000px;\n            width: 100%;\n        }\n\n        @media (max-width: 768px) { .container { grid-template-columns: 1fr; } }\n\n        .section {\n            background: var(--card-bg);\n            padding: 20px;\n            border-radius: 8px;\n            border: 1px solid #30363d;\n        }\n\n        h2 { color: var(--accent); margin-top: 0; }\n\n        input, textarea {\n            width: 100%;\n            padding: 10px;\n            margin: 10px 0;\n            border-radius: 6px;\n            border: 1px solid #30363d;\n            background: #0d1117;\n            color: white;\n            box-sizing: border-box;\n            font-family: monospace;\n        }\n\n        button {\n            background: var(--accent);\n            color: #0d1117;\n            padding: 10px 15px;\n            border: none;\n            border-radius: 6px;\n            cursor: pointer;\n            font-weight: bold;\n            margin-right: 5px;\n        }\n\n        button:hover { opacity: 0.8; }\n        .error { color: var(--error); font-size: 0.9em; margin-top: 5px; }\n        .copy-btn { background: #30363d; color: white; }\n    <\/style>\n<\/head>\n<body>\n\n<header>\n    <h1>Password Encryption &#038; Decryption<\/h1>\n    <p>Secure AES-GCM encryption using Web Crypto API. <b>Requires HTTPS or Localhost.<\/b><\/p>\n<\/header>\n\n<div class=\"container\">\n    <div class=\"section\">\n        <h2>Encrypt<\/h2>\n        <textarea id=\"plain-text\" rows=\"4\" placeholder=\"Enter text to encrypt...\"><\/textarea>\n        <input type=\"password\" id=\"enc-pass\" placeholder=\"Master Password\">\n        <button onclick=\"handleEncrypt()\">Encrypt<\/button>\n        <button class=\"copy-btn\" onclick=\"genPassword()\">Generate Random Pass<\/button>\n        <textarea id=\"enc-output\" rows=\"4\" readonly placeholder=\"Encrypted string will appear here...\"><\/textarea>\n        <button class=\"copy-btn\" onclick=\"copyToClipboard('enc-output')\">Copy Output<\/button>\n    <\/div>\n\n    <div class=\"section\">\n        <h2>Decrypt<\/h2>\n        <textarea id=\"cipher-text\" rows=\"4\" placeholder=\"Enter salt:iv:ciphertext...\"><\/textarea>\n        <input type=\"password\" id=\"dec-pass\" placeholder=\"Master Password\">\n        <button onclick=\"handleDecrypt()\">Decrypt<\/button>\n        <textarea id=\"dec-output\" rows=\"4\" readonly placeholder=\"Decrypted text will appear here...\"><\/textarea>\n        <button class=\"copy-btn\" onclick=\"copyToClipboard('dec-output')\">Copy Output<\/button>\n        <div id=\"error-msg\" class=\"error\"><\/div>\n    <\/div>\n<\/div>\n\n<script>\n    \/\/ Web Crypto check\n    if (!window.crypto || !window.crypto.subtle) {\n        alert(\"Web Crypto API is not available! Please ensure you are using HTTPS.\");\n    }\n\n    async function deriveKey(password, salt) {\n        const encoder = new TextEncoder();\n        const baseKey = await crypto.subtle.importKey(\"raw\", encoder.encode(password), \"PBKDF2\", false, [\"deriveKey\"]);\n        return crypto.subtle.deriveKey(\n            { name: \"PBKDF2\", salt: salt, iterations: 100000, hash: \"SHA-256\" },\n            baseKey,\n            { name: \"AES-GCM\", length: 256 },\n            false,\n            [\"encrypt\", \"decrypt\"]\n        );\n    }\n\n    async function handleEncrypt() {\n        try {\n            const password = document.getElementById(\"enc-pass\").value;\n            const text = document.getElementById(\"plain-text\").value;\n            const salt = crypto.getRandomValues(new Uint8Array(16));\n            const iv = crypto.getRandomValues(new Uint8Array(12));\n            const key = await deriveKey(password, salt);\n\n            const encoded = new TextEncoder().encode(text);\n            const ciphertext = await crypto.subtle.encrypt({ name: \"AES-GCM\", iv }, key, encoded);\n\n            const result = [\n                btoa(String.fromCharCode(...salt)),\n                btoa(String.fromCharCode(...iv)),\n                btoa(String.fromCharCode(...new Uint8Array(ciphertext)))\n            ].join(\":\");\n            \n            document.getElementById(\"enc-output\").value = result;\n        } catch (e) { alert(\"Encryption failed: \" + e.message); }\n    }\n\n    async function handleDecrypt() {\n        try {\n            const [s, i, c] = document.getElementById(\"cipher-text\").value.split(\":\");\n            const password = document.getElementById(\"dec-pass\").value;\n            \n            const salt = Uint8Array.from(atob(s), c => c.charCodeAt(0));\n            const iv = Uint8Array.from(atob(i), c => c.charCodeAt(0));\n            const data = Uint8Array.from(atob(c), c => c.charCodeAt(0));\n\n            const key = await deriveKey(password, salt);\n            const decrypted = await crypto.subtle.decrypt({ name: \"AES-GCM\", iv }, key, data);\n            \n            document.getElementById(\"dec-output\").value = new TextDecoder().decode(decrypted);\n            document.getElementById(\"error-msg\").textContent = \"\";\n        } catch (e) {\n            document.getElementById(\"error-msg\").textContent = \"Decryption failed! Wrong password or corrupted data.\";\n        }\n    }\n\n    function genPassword() {\n        const chars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()\";\n        let pass = \"\";\n        for (let i = 0; i < 24; i++) pass += chars.charAt(Math.floor(Math.random() * chars.length));\n        document.getElementById(\"plain-text\").value = pass;\n    }\n\n    function copyToClipboard(id) {\n        const el = document.getElementById(id);\n        el.select();\n        document.execCommand(\"copy\");\n    }\n<\/script>\n\n<\/body>\n<\/html>\n","protected":false},"excerpt":{"rendered":"<p>Password &#038; Text Encryption Tool Password Encryption &#038; Decryption Secure AES-GCM encryption using Web Crypto API. Requires HTTPS or Localhost. Encrypt Encrypt Generate Random Pass Copy Output Decrypt Decrypt Copy Output<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-555","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/freewebtools.co.in\/index.php\/wp-json\/wp\/v2\/pages\/555","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/freewebtools.co.in\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/freewebtools.co.in\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/freewebtools.co.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/freewebtools.co.in\/index.php\/wp-json\/wp\/v2\/comments?post=555"}],"version-history":[{"count":1,"href":"https:\/\/freewebtools.co.in\/index.php\/wp-json\/wp\/v2\/pages\/555\/revisions"}],"predecessor-version":[{"id":556,"href":"https:\/\/freewebtools.co.in\/index.php\/wp-json\/wp\/v2\/pages\/555\/revisions\/556"}],"wp:attachment":[{"href":"https:\/\/freewebtools.co.in\/index.php\/wp-json\/wp\/v2\/media?parent=555"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}