← All topics

#cryptography

4 min read

Encryption in Laravel and PHP: Crypt, APP_KEY and sodium

Laravel's Crypt::encryptString() uses OpenSSL AES-256-CBC and signs every value with a MAC. Generate APP_KEY with php artisan key:generate, never commit it, and use APP_PREVIOUS_KEYS when you rotate. In plain PHP, use the sodium extension's documented secretbox API rather than a home-grown cipher.

Get new briefs by email

Short alerts when a PHP or WordPress vulnerability needs action.

Double opt-in via Buttondown; unsubscribe any time. See our privacy policy.