Fernet Encrypt/Decrypt
Encrypt or decrypt Fernet tokens with WebCrypto: HMAC verification, TTL checks and full token anatomy. Keys stay in your tab.
Keys are held in this tab only — never sent to a server or saved to local storage. Pasting production secrets is at your own risk.
Fernet token
Plaintext
Paste a token and enter its key to decrypt
Nothing leaves the browser. Try a Python-generated sample above.
Token anatomy
A valid token and key reveal the field layout, HMAC comparison and issued time here.
Details
This tool implements the frozen Fernet spec exactly with WebCrypto: a 32-byte key whose first 16 bytes sign and last 16 bytes encrypt; a 0x80 version byte, 8-byte big-endian timestamp, 16-byte IV, AES-128-CBC ciphertext and a 32-byte HMAC-SHA256. The HMAC is compared in constant time before any decryption is attempted, then an optional TTL is checked against the device clock or a chosen 'as of' time. Output is standard urlsafe base64 with the trailing '=' padding that Python's cryptography emits, so tokens copy straight back into Fernet.decrypt(). Payloads that are not UTF-8 are shown as hex with a raw-byte download. No key, token or plaintext is uploaded or stored; everything lives in this tab and is cleared when it closes.
More examples
Read a Python-generated token
Key: AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8=
Token: gAAAAABfXhAA1GJm5qItCM5lVZjQrs_NI4AyiJ629pxjrFkexCqquot9vhcm8dGNOVXJcqvwv6tTi86LAuAB1fiJuxXcCCKzgQ==
Plain: hello fernetThe fixed key and token were generated with cryptography.fernet.Fernet.encrypt_at_time(); the anatomy panel decodes the timestamp, IV, ciphertext and HMAC.
Check an expired token
Issued: 2020-09-13T12:26:40Z
TTL: 60 seconds
As of: 1600000061 (2020-09-13T12:27:41Z)
Result: age 61 seconds exceeds the 60 second TTLTTL checks reject only tokens OLDER than the limit. Set an explicit 'as of' Unix time to test boundaries without depending on your device clock.
Encrypt a unicode message
Plaintext: café ✓ — ü ö ç “curly”
Key: generated 32-byte urlsafe key
Token: gAAAAA… (urlsafe base64, padded for Python)Text is UTF-8 encoded, AES-CBC encrypted with a fresh random IV, then signed. The output decrypts unchanged in cryptography.fernet.Fernet.
Examples
Python-generated ASCII token
Key: AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8=
Token: gAAAAABfXhAA1GJm5qItCM5lVZjQrs_NI4AyiJ629pxjrFkexCqquot9vhcm8dGNOVXJcqvwv6tTi86LAuAB1fiJuxXcCCKzgQ==hello fernet
Version 0x80 · issued 2020-09-13T12:26:40Z · HMAC matchA fixed vector produced with cryptography 50.0.0's encrypt_at_time(), so the timestamp and every field are deterministic.
TTL boundary
Issued 1600000000 · TTL 60 s · as of 1600000061Token expired: age 61 seconds exceeds the 60 second TTLSetting an explicit reference time makes the boundary repeatable; at 1600000060 the same token would still be valid.
Unicode round trip
café ✓ — ü ö ç “curly”gAAAAA… → decrypts back to the same characters, byte for byteUTF-8 encoding happens before AES-CBC; typographic marks and em-dashes are never normalised or mangled.
About this tool
Fernet is a small, frozen format for authenticated tokens: Python's cryptography library uses it for encrypted cookies, signed URLs, Internal tickets and one-time links. This tool speaks that exact format in your browser. Paste a token and its 32-byte key to read the plaintext, or encrypt UTF-8 text into a token that Python can decrypt unchanged.
A token is laid out as a 0x80 version byte, an 8-byte big-endian Unix timestamp, a 16-byte IV, AES-128-CBC ciphertext and a 32-byte HMAC-SHA256. The key is split in half: the first 16 bytes sign, the last 16 bytes encrypt. Fernet is encrypt-then-MAC, so the HMAC covering version, timestamp, IV and ciphertext is verified in constant time before any decryption is attempted. A wrong key or a flipped ciphertext byte is reported as an authentication failure with no partial plaintext.
Decryption also exposes the token anatomy: issued time in UTC and Unix seconds, age relative to now, IV, ciphertext length, the HMAC carried by the token and the HMAC computed with your key. An optional TTL rejects tokens older than the limit; an 'as of' reference time lets you test expiry boundaries deterministically. Tokens from the future are shown with a negative age and are not rejected, matching the spec's older-only check.
Encryption uses WebCrypto's AES-CBC, which applies PKCS#7 padding itself, a fresh CSPRNG IV for every token and urlsafe base64 with the trailing '=' padding that cryptography emits. Keys, tokens and plaintext never leave the tab: there is no network call, no localStorage and no account. Payloads that are not valid UTF-8 — serialized sessions, msgpack or compressed blobs — are shown as hex and can be downloaded as raw bytes.
What this tool does not do
- Only the original 0x80 Fernet format is supported; MultiFernet key lists, key rotation and custom TTL policies are outside this tool.
- TTL is checked against the device clock unless an explicit 'as of' Unix time is entered; an inaccurate clock changes the result.
- There is no password-based key derivation: the input must be a 32-byte urlsafe-base64 key, not a passphrase.
- Decryption handles one token at a time; no file, batch or streaming modes are provided.
- Binary payloads are shown as hex with a raw-byte download rather than being decoded as text.
- Keys and plaintext are kept in tab memory, but secrets pasted into any browser tool may still be exposed by local malware or an unsafe clipboard; do not use production keys on an untrusted machine.
- WebCrypto is required, so the tool needs a secure context (HTTPS or localhost) and a current browser.
How to use this tool
Choose a mode
Use Decrypt to inspect an existing token, or Encrypt to make one. Pasted tokens are detected automatically.
Enter the key
Paste the 32-byte urlsafe-base64 key (44 characters including the trailing '='), or generate a fresh one. The key splits visually into its 16-byte signing and 16-byte encryption halves.
Paste the token or text
On Decrypt, paste the whole gAAAAA… token; newlines, spaces and missing padding are tolerated. On Encrypt, type UTF-8 text — an empty payload is allowed.
Set a TTL if needed
Enter a non-negative number of seconds to reject old tokens, and optionally an 'as of' Unix time to check expiry without relying on the device clock.
Read the anatomy
Check the version byte, issued timestamp, age, IV, ciphertext length and the HMAC match badge. Copy individual fields or download raw bytes.
Use cases
Debug a Django-adjacent token
Inspect a Fernet token issued by Python services — one-time links, encrypted queue payloads or configuration blobs — without installing cryptography locally.
Verify TTL behavior
Check whether an issued token is still inside its 60-second window, or replay the exact boundary with an explicit 'as of' time.
Teach authenticated encryption
Show the field layout, key halves and HMAC-first verification order side by side with a tampered token that fails before decryption.
Token layout and accepted inputs
| Part | Size / behavior |
|---|---|
| Version | 1 byte, 0x80 — other versions are reported as unsupported |
| Timestamp | 8 bytes, unsigned big-endian Unix seconds, shown as UTC ISO and integer seconds |
| IV | 16 bytes, randomly generated on encrypt and hex-encoded in the anatomy table |
| Ciphertext | AES-128-CBC, a non-zero multiple of 16 bytes with PKCS#7 padding applied by WebCrypto |
| HMAC | 32 bytes of HMAC-SHA256 over version, timestamp, IV and ciphertext, using the first 16 key bytes |
| Encoding | urlsafe base64; input accepts '-'/'_', '+'/'/', optional '=' padding and surrounding whitespace; output uses Python-compatible padded urlsafe base64 |
| Key | 32 bytes decoded from urlsafe or standard base64, 43 characters unpadded or 44 with '=' |
Fernet is encrypt-then-MAC: the token HMAC is checked before AES decryption, and TTL is checked after authentication but before decryption.
Common mistakes
Mistake:Stripping the '=' padding from a copied token before pasting it into Python.
Fix:Keep the padded output toggle on. cryptography's urlsafe_b64decode needs padding whenever the encoded length is not a multiple of four; use 'Copy unpadded' only for APIs that demand it.
Mistake:Assuming a wrong key yields garbled plaintext rather than an error.
Fix:Fernet is encrypt-then-MAC: a wrong key fails HMAC verification, and this tool reports an authentication failure without attempting AES decryption.
Mistake:Treating TTL as an absolute expiry date.
Fix:TTL is a maximum age in seconds measured from the token timestamp. A token from the future has a negative age and is not rejected by the spec.
Mistake:Pasting a Django signed cookie and expecting Fernet output.
Fix:django.core.signing uses its own HMAC construction, not Fernet. Use this tool only for tokens created by cryptography.fernet.Fernet or a compatible implementation.
Mistake:Expecting a key derived from a password.
Fix:Fernet keys are already 32 random bytes. There is no password-based key derivation here; use a key generator outside the tool if you need PBKDF2.
Frequently asked questions
What is the Fernet token format?
A Fernet token is urlsafe base64 wrapping five fields in order: a 0x80 version byte, an 8-byte big-endian Unix timestamp, a 16-byte IV, AES-128-CBC ciphertext (a non-zero multiple of 16 bytes) and a 32-byte HMAC-SHA256. The token anatomy panel decodes each field and shows its size, so you can compare a token against the spec without running Python.
How is the key structured?
A Fernet key is 32 random bytes, normally written as 44 urlsafe-base64 characters with a trailing '='. The first 16 bytes are the signing key and the last 16 bytes are the AES encryption key. The tool shows both halves in hex as soon as it accepts a key.
Why is the HMAC verified before decryption?
Fernet is encrypt-then-MAC: the HMAC covers the version, timestamp, IV and ciphertext, and a receiver must reject a bad MAC before treating any decrypted bytes as real data. This tool compares the HMAC in constant time and stops on a mismatch, so a wrong key or a modified token never produces partial plaintext. That is why it cannot tell you which of the two happened.
How does TTL checking work?
TTL is a maximum age in seconds, not an absolute expiry date. Token age is the reference time minus the timestamp; only an age greater than the TTL fails. By default the reference time is your device clock; enter a Unix time in the 'as of' field to reproduce an exact boundary. A token from the future has a negative age and is accepted.
Will Python's cryptography decrypt a token from this tool?
Yes. Encryption uses the exact Fernet construction with a fresh random IV, WebCrypto's built-in PKCS#7 padding and urlsafe base64 including the trailing '=' that cryptography emits. Copy the padded token (the default) and pass the same key to Fernet.decrypt(). Use the unpadded copy button only for APIs that require the stripped form.
Can it decrypt serialized or binary payloads?
Yes. Plaintext bytes are preserved regardless of content. If they are not valid UTF-8 — a pickled session, msgpack or compressed data — the result panel switches to hex and offers a base64 copy button plus a raw-byte download instead of substituting replacement characters.
Is my key sent anywhere or saved?
No. Key decoding, HMAC verification, AES-CBC, TTL checks and anatomy rendering all run in this browser tab. There is no network request and no localStorage entry; the fields are cleared when the tab is closed. Clipboard and local malware are outside the browser's control, so avoid pasting production secrets on an untrusted machine.
Can it read Django signed cookies?
No. Django's signing module uses a different HMAC-based format, not Fernet. This tool is for tokens produced by cryptography.fernet.Fernet or compatible implementations. If you are debugging a Django session cookie, inspect it with Django's own signing tools instead.
What happens with an expired or tampered token?
An expired token is rejected with its age and the configured TTL; a tampered token fails HMAC verification with a red authentication banner before decryption. In both cases the anatomy table still shows the token fields and the computed HMAC so you can see exactly why it was rejected.
Why doesn't this tool derive a key from my password?
Fernet deliberately takes a random 32-byte key and has no password-based key derivation step. Adding PBKDF2 here would produce a non-standard key and a false sense of interoperability; generate a key with the button or with Fernet.generate_key() in Python instead.
References & standards
Related tools
AES Encryption
Encrypt and decrypt text with AES-GCM and a passphrase, fully in your browser. Uses PBKDF2 key derivation and the Web Crypto API — your data and keys never leave your device.
Android Network Security Config Builder
Generate network_security_config.xml with cleartext rules, trust anchors, certificate pinning and debug-only CAs — plus the manifest snippet and file placement checklist.
Ansible Vault Encrypt/Decrypt
Encrypt secrets into $ANSIBLE_VAULT;1.1;AES256 format or decrypt vault content with its password — locally in your browser, drop-in compatible with ansible-vault.
Argon2 Hash Generator & Verifier
Generate Argon2id/2i/2d hashes with proper m/t/p parameters and verify PHC strings — reference algorithm in your browser, nothing uploaded.
AWS Signature V4 Builder
Build AWS Signature V4 headers and presigned URLs from a canonical request — signed curl, key chain and debug diff, computed locally in your browser.
Basic Auth Generator
Generate an HTTP Basic Authentication header from a username and password. Produces the Authorization header and ready-to-use curl and fetch snippets. Runs fully client-side.