.env · security

Altcha HMAC Key Generator

Generate a cryptographically strong ALTCHA_HMAC_KEY for Altcha proof-of-work CAPTCHA. 256-bit hex key, generated in-browser — nothing is uploaded.

Be the first to rate
ALTCHA_HMAC_KEY (hex, 32 bytes)
HMAC-SHA256 key used to sign and verify Altcha proof-of-work challenges
Raw secret
.env line
ALTCHA_HMAC_KEY=
Usage (altcha-lib, Node.js)
import { createChallenge } from 'altcha-lib'; const challenge = await createChallenge({ hmacKey: process.env.ALTCHA_HMAC_KEY!, maxNumber: 100000, });

What it does

  • 256-bit (32 byte) hex key, matching Node's crypto.randomBytes(32).toString('hex')
  • Runs entirely in-browser with crypto.getRandomValues
  • One-click copy of raw key or full ALTCHA_HMAC_KEY=… .env line

Privacy

Runs 100% in your browser. Your .env never touches our servers.

client-side only

When to use this tool

  • Setting up Altcha proof-of-work CAPTCHA on a new form
  • Rotating a leaked or accidentally committed HMAC key
  • Provisioning a distinct key per environment (dev/staging/prod)
  • Replacing a placeholder key left in .env.example

Common mistakes

  • Reusing the same ALTCHA_HMAC_KEY across dev, staging, and production
  • Committing the key to git inside .env instead of .env.example
  • Using a short or predictable string instead of a full 32-byte random value
  • Verifying challenges without a server-side HMAC check at all

What is Altcha?

Altcha is an open-source, self-hostable CAPTCHA alternative based on proof-of-work rather than tracking or image puzzles. The server issues a signed challenge; the client's browser solves it with a small amount of computation, then submits the solution back for verification.

The signature on each challenge is an HMAC-SHA256 computed with a secret key — ALTCHA_HMAC_KEY. Anyone who knows this key can forge valid-looking solutions, so it must stay server-side only and never ship to the client bundle.

How to add it to your project

  1. Copy the generated key into your server-side .env:
    ALTCHA_HMAC_KEY=<paste here>
  2. Pass it to altcha-lib when creating and verifying challenges:
    import { createChallenge, verifySolution } from 'altcha-lib';
    
    const challenge = await createChallenge({
      hmacKey: process.env.ALTCHA_HMAC_KEY!,
    });
    
    const ok = await verifySolution(payload, process.env.ALTCHA_HMAC_KEY!);
  3. Never expose ALTCHA_HMAC_KEY to the client — it belongs only in server-side environment variables (API routes, Edge Functions), not in NEXT_PUBLIC_* or client bundles.

Frequently asked questions

What is ALTCHA_HMAC_KEY used for?

Altcha is a privacy-first, proof-of-work CAPTCHA alternative. The server signs each challenge with an HMAC-SHA256 key so it can later verify the client's solution wasn't forged or replayed. That key is the ALTCHA_HMAC_KEY (or hmacKey option in altcha-lib).

How long should the key be?

32 bytes (256 bits) of hex, matching HMAC-SHA256's block size, is the standard choice and what this tool generates. Altcha itself doesn't enforce a minimum length, but shorter keys reduce the security margin.

Can I use the same key across environments?

No — use a different ALTCHA_HMAC_KEY per environment (dev, staging, production). If it leaks in one environment, only that environment's challenges are compromised.

Is the generated key uploaded anywhere?

No. It's generated entirely in your browser using crypto.getRandomValues, the same CSPRNG used by Node's crypto.randomBytes and OpenSSL. Nothing is sent to any server.

Related tools

coming soon

Get notified when env syncing launches

We're building a tiny tool to keep .env files in sync across teammates and environments. Leave your email — no spam, just a single launch ping.