You can encrypt HTML content at-rest using Laravel's encryption. Specify 'encrypted' => true for specific fields in your configuration.
protected $richTextAttributes = [
'body' => ['encrypted' => true],
'notes',
];
If you need to customize the encryption/decryption logic (e.g., for key rotation or compatibility), use RichTextLaravel::encryptUsing() in your AppServiceProvider::boot() method.
namespace App//\Providers;
use Illuminate//\Support\Facades\Crypt;
use Illuminate//\Support\ServiceProvider;
use Tonysm//\RichTextLaravel\RichTextLaravel;
class AppServiceProvider extends ServiceProvider
{
public function boot(): void
{
RichTextLaravel::encryptUsing(
encryption: fn ($value, $model, $key) => Crypt::encrypt($value),
decryption: fn ($value, $model, $key) => Crypt::decrypt($value),
);
}
}