Skip to content

3.0.0

Compare
Choose a tag to compare
@tonysm tonysm released this 16 Mar 19:36
· 16 commits to main since this release
960e096

What's Changed

  • Default to encryptString and decryptString by @tonysm in #53

Full Changelog: 2.2.0...3.0.0


Upgrade Guide

In 2.2.0 we introduced a new recommended way to encrypt data, which uses Laravel's Crypt::encryptString() instead of Crypt::encrypt(). This is now the default in v3. If you're migrating from 2.x and have existing data stored encrypted, but not using the recommendation in the 2.2.0 release note, you must migrate them (see instructions below).

Migrating Existing Encrypted Data

If you only have encrypted rich text attributes in your application, you may create a new migration and loop through the stored data, encrypting and decrypting it:

DB::table('rich_texts')->whereNotNull('body')->eachById(function ($richText) {
  DB::table('rich_texts')
    ->where('id', $richText->id)
    ->update([
      'body' => Crypt::encryptString(Crypt::decrypt($richText->body)),
    ]);
});

If you have a mix of encrypted and plain text rich text attributes, you will have to check if the $richText->field and $richText->record_type fields match the entities and attribute that are using encryption:

DB::table('rich_texts')
  ->whereNotNull('body')
  ->where('field', 'content')
  ->where('record_type', (new Post())->getMorphClass())
  ->eachById(function ($richText) {
    DB::table('rich_texts')
      ->where('id', $richText->id)
      ->update([
        'body' => Crypt::encryptString(Crypt::decrypt($richText->body)),
      ]);
  });