Encrypt/decrypt

I need to ENCRYPT/DECRYPT a password on the Client-Side using APPSTUDIO. Suggenstions?

In general, this isn’t possible. Your code on the client side is visible to anyone, meaning they could read how you are doing encryption and decryption.

However, it might be different in your specific use case. Can you explain more about what you are doing?

Claude AI’s answer to this question goes into more detail:

Client-side decryption in JavaScript is usually done with the Web Crypto API (window.crypto.subtle), which is built into every modern browser — no libraries needed for standard algorithms like AES-GCM or RSA-OAEP.

Here’s a common pattern: AES-GCM (symmetric encryption, most typical for “encrypt on server/elsewhere, decrypt in browser” use cases):

async function decryptAESGCM(base64Ciphertext, base64Iv, rawKeyBytes) {
  // Import the raw key
  const key = await crypto.subtle.importKey(
    "raw",
    rawKeyBytes,           // Uint8Array, e.g. 32 bytes for AES-256
    { name: "AES-GCM" },
    false,                 // not extractable
    ["decrypt"]
  );

  const iv = Uint8Array.from(atob(base64Iv), c => c.charCodeAt(0));
  const ciphertext = Uint8Array.from(atob(base64Ciphertext), c => c.charCodeAt(0));

  const decrypted = await crypto.subtle.decrypt(
    { name: "AES-GCM", iv },
    key,
    ciphertext
  );

  return new TextDecoder().decode(decrypted); // back to plaintext string
}

Usage:

const keyBytes = Uint8Array.from(atob(base64Key), c => c.charCodeAt(0));
const plaintext = await decryptAESGCM(cipherB64, ivB64, keyBytes);

A few things worth knowing before you build on this:

Key delivery is the hard part, not the decryption call itself. Wherever the key comes from — a password-derived key (PBKDF2/Argon2), a server response, a QR code, etc. — that’s the actual security boundary. subtle.decrypt is trivial; getting the key to the browser safely is the real design problem.

Client-side decryption doesn’t hide anything from a sufficiently motivated user of that browser. The key and plaintext both exist in browser memory and are inspectable via devtools. This is fine for “protect data in transit / at rest from a server operator” (e.g., E2E encryption schemes) but doesn’t protect against the person sitting at that browser.

For password-based decryption, derive the AES key with PBKDF2 rather than hashing a password directly:

async function deriveKey(password, saltBytes) {
  const baseKey = await crypto.subtle.importKey(
    "raw", new TextEncoder().encode(password), "PBKDF2", false, ["deriveKey"]
  );
  return crypto.subtle.deriveKey(
    { name: "PBKDF2", salt: saltBytes, iterations: 250000, hash: "SHA-256" },
    baseKey,
    { name: "AES-GCM", length: 256 },
    false,
    ["decrypt"]
  );
}

What’s the actual use case — decrypting data fetched from a server, a password-protected file/message, something end-to-end encrypted? That’ll determine whether AES-GCM is even the right algorithm (vs. RSA-OAEP for asymmetric, or a library like libsodium.js if you want NaCl-style boxes).