What's inside a JWT
A JSON Web Token is three base64url strings joined by dots. The header names the signing algorithm (alg) and often the key (kid). The payload holds the claims: who the token is about (sub), who issued it (iss), who it's for (aud) and when it expires (exp, in seconds since 1970). The signature covers the first two parts, so changing a single character of the payload makes verification fail.
HS algorithms sign with one shared secret, so whoever can verify a token can also create one. RS, PS and ES algorithms sign with a private key and verify with a public key, which is why identity providers such as Keycloak publish their public keys as a JWKS.
Choosing an AES mode
- AES-GCM is the best default for new work: it encrypts and authenticates, so tampering is detected. Use a 12-byte random IV and never reuse it with the same key.
- AES-CBC is what many existing systems use. It needs a random 16-byte IV per message and doesn't detect tampering on its own, so pair it with an HMAC or a signed token.
- AES-CTR turns AES into a stream cipher with no padding. Reusing a counter with the same key exposes the plain text.
The IV doesn't need to be secret, only unique, so systems often send it in front of the ciphertext. Tick "IV sits at the start of the ciphertext" to handle that format.
Frequently asked questions
Is it safe to paste a real token or key here?
Tokens, secrets, keys and data are processed only in your browser with the Web Crypto API and never sent anywhere. Even so, treat production secrets with care: prefer test keys, and rotate any secret you've pasted somewhere you don't control.
Which JWT algorithms can it verify?
HS256, HS384 and HS512 with a shared secret (as text or base64), and RS256/384/512, PS256/384/512 and ES256/384/512 with a public key. Paste the key as a PEM public key (-----BEGIN PUBLIC KEY-----) or as JWK JSON; with a JWKS (for example from a Keycloak or Auth0 certs URL) the key matching the token's kid is used.
Why does decoding work without the secret?
A JWT's header and payload are only base64url-encoded, not encrypted, so anyone holding the token can read them. The signature only proves the token wasn't changed. Never put passwords or other secrets in a JWT payload.
Which AES modes are supported?
AES-CBC with PKCS#7 padding, AES-GCM (the 16-byte authentication tag is expected at the end of the ciphertext, as Node.js, Java and Web Crypto produce once you append it), and AES-CTR, each with 128- or 256-bit keys. Keys and IVs can be text, hex or base64, and the IV can be read from the start of the ciphertext, a common way to store it.
How do I decrypt something encrypted with CryptoJS.AES.encrypt(text, 'passphrase')?
Choose the Passphrase mode. When CryptoJS (or openssl enc) is given a passphrase instead of a key, it picks a random salt, derives a 256-bit key and IV from the passphrase with MD5, and outputs base64 starting with U2FsdGVkX1, which is "Salted__". The tool reverses exactly that, and can produce the same format.
Decryption fails with a padding error. What's wrong?
In CBC mode that almost always means the key or IV doesn't match: check that each is in the right encoding (text, hex or base64), that the key length gives the AES size you expect, and whether the IV is stored at the start of the ciphertext. In GCM mode a failure also means the data or tag was changed.