Fernet decrypt and encrypt

Runs in your browser

Paste a Fernet token (gAAAAA…) and the key. You get the text and the time it was made; the HMAC is checked. Nothing leaves your browser.

More options
Waiting for input

Paste the token and the key

Fernet tokens from Python (cryptography.fernet, also Airflow and Django apps). Rails credentials.yml.enc works too.

Examples

Start from an example

Each example fills in the tool above and decrypts it. All keys and passwords are demo values made for this page.

The format

What is inside a Fernet token

BytesWhat it is
1Version 0x80 (Base64 starts with gAAAAA)
2–9Time of creation, seconds since 1970
10–25IV, 16 bytes
26–…AES-128-CBC data
last 32HMAC-SHA256 over everything before

The key is 32 bytes as URL-safe Base64: the first half signs (HMAC), the second half encrypts (AES-128). MultiFernet tries several keys in order; paste them one per line.

In your code

The same in Python

Decrypt
from cryptography.fernet import Fernet
Fernet(key).decrypt(token)            # bytes
Fernet(key).decrypt(token, ttl=3600)  # refuses older tokens
New key
Fernet.generate_key()
Rails
EDITOR=cat bin/rails credentials:show
RAILS_MASTER_KEY=… bin/rails credentials:show
Also on this page

Rails credentials

config/credentials.yml.enc is data--iv--tag: AES-128-GCM with the 32 hex characters of config/master.key (or RAILS_MASTER_KEY). Inside is the YAML, serialized with Ruby’s Marshal; the tool unpacks it.

Under the hood

Tested against the original tools

Every format on this page was checked against values made by the real tool, on 3 December 2026:

  • Fernet tokens from Python cryptography, MultiFernet key lists, wrong keys; what the tool creates, Python decrypts.
  • Rails credentials made with Ruby’s OpenSSL and Marshal as in ActiveSupport::EncryptedFile; what the tool creates, Ruby reads.
More formats

Other encrypted formats

Every format has its own page with the same tool. Paste anything into one of them: if it belongs elsewhere, the tool says so and takes it there.

FAQ

Questions about Fernet

How do I decrypt a Fernet token?

Paste the token and the key above, or in Python: Fernet(key).decrypt(token).

What does InvalidToken mean?

The HMAC doesn’t match (wrong key, changed token) or, with ttl, the token is too old. The tool shows when it was made.

Can I tell when a token was created?

Yes, without the key: the time is in plain bytes 2 to 9. The tool shows it after decrypting.

Is it safe to paste the key here?

Everything runs in your browser: nothing you paste is sent anywhere, not even to this site. The page’s Content-Security-Policy blocks connections to other sites; check the Network tab of your browser’s developer tools.

Searches the list of pages on this site. What you type stays in your browser.