Skip to content
gohacks.dev
Standard Library

Laravel Encrypt and Decrypt

Decrypt a Laravel encrypted value or cookie with its APP_KEY, or encrypt one, using the same AES-256-CBC and HMAC scheme as Crypt::encrypt().

Free · No sign-up · Your inputs stay in your browser

Input

Encrypt or decrypt Laravel encrypted values

Output

Encrypted payload

Laravel's Encrypter: AES-256-CBC with a random IV and an HMAC-SHA256 over iv and value, all wrapped in Base64 JSON. When a payload fails after a deploy, the APP_KEY changed; APP_PREVIOUS_KEYS (Laravel 11+) lets old payloads keep decrypting during a rotation.

Runs in this browser. Nothing you paste is sent to a server.

The payload format

Laravel's Encrypter generates a random 16-byte IV, encrypts the serialized value with AES-256-CBC, and computes an HMAC-SHA256 over the Base64 IV and Base64 ciphertext with the same key. The IV, value, MAC and an empty tag are JSON-encoded and the JSON is Base64-encoded. The encryption docs describe the API; the format is in Illuminate\Encryption\Encrypter.

Why decryption fails after a deploy

A 'MAC is invalid' error means the payload was encrypted with a different key, usually because APP_KEY changed. Since Laravel 11, listing old keys in APP_PREVIOUS_KEYS lets existing cookies, sessions and stored values keep decrypting while new ones use the current key.

Handle real keys with care

The APP_KEY decrypts every cookie and session of the application. This page never sends it anywhere, but the sample key is the one to experiment with; read the source of any page before pasting a production key into it.

Share

Frequently asked questions

What is the difference between encrypt() and encryptString()?
encrypt() serializes the value first, so arrays and objects round-trip; encryptString() encrypts the string as it is. Decrypting one with the other's counterpart gives serialized text or an error.
Why does a decrypted cookie start with a long hex string and a |?
Laravel prefixes encrypted cookie values with an HMAC of the cookie name and a |, which ties each value to its cookie so it cannot be replayed under another name. The tool strips it.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools