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.
