From 5d99d7942ed5b482fb0dde38afcf213a6c9060de Mon Sep 17 00:00:00 2001 From: sandeep0108 <141115428+sandeep0108@users.noreply.github.com> Date: Thu, 4 Jan 2024 16:22:27 +0530 Subject: [PATCH 1/5] Update README.md --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index e82a9e9..8b87ab8 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,20 @@ DB::statement('ALTER TABLE `users` ADD `last_name` VARBINARY(300)'); DB::statement('ALTER TABLE `users` ADD `email` VARBINARY(300)'); DB::statement('ALTER TABLE `users` ADD `telephone` VARBINARY(50)'); ``` +## Implementing encryption for existing data + +For this you can create one command like + +``` +php artisan make:command EncryptionForExistingData +``` + +In this command you fetch existing table or model data without global scope `DecryptSelectScope`. + +You can refer the example, clicking on below example button: + + + ## License From df40fca06e8001bb84651c791722ca859bc25bd3 Mon Sep 17 00:00:00 2001 From: sandeep0108 <141115428+sandeep0108@users.noreply.github.com> Date: Thu, 4 Jan 2024 16:23:15 +0530 Subject: [PATCH 2/5] Create existing_data_encryption.md --- existing_data_encryption.md | 63 +++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 existing_data_encryption.md diff --git a/existing_data_encryption.md b/existing_data_encryption.md new file mode 100644 index 0000000..c70aaf7 --- /dev/null +++ b/existing_data_encryption.md @@ -0,0 +1,63 @@ + +## Example of existing data encryption + +```php +error("Model '{$modelName}' not found!"); + + return; + } + + // Instantiate the model + $modelObj = new $modelName; + $modelData = $modelObj->withoutGlobalScopes([DecryptSelectScope::class])->get(); + + foreach ($modelData as $modelRecord) { + $updateModel = $modelName::findOrFail($modelRecord->id); + $fields = $updateModel->encryptable; + foreach ($fields as $field) { + $updateModel->$field = $modelRecord->$field; + } + $updateModel->save(); + } + } + + } +} +``` From 0c22ccdfc3ec23ee7caecf79e2cc58638f62c409 Mon Sep 17 00:00:00 2001 From: sandeep0108 <141115428+sandeep0108@users.noreply.github.com> Date: Thu, 4 Jan 2024 16:24:22 +0530 Subject: [PATCH 3/5] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 8b87ab8..8ed5159 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Laravel/Lumen MySql AES Encrypt/Decrypt +Total Downloads Latest Stable Version License + Laravel/Lumen database encryption at database side using native AES_DECRYPT and AES_ENCRYPT functions. Automatically encrypt and decrypt fields in your Models. From 3a08ed322e561861eb43427e07da6c416c7616b4 Mon Sep 17 00:00:00 2001 From: sandeep0108 <141115428+sandeep0108@users.noreply.github.com> Date: Thu, 4 Jan 2024 16:27:08 +0530 Subject: [PATCH 4/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8ed5159..d230088 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Laravel/Lumen MySql AES Encrypt/Decrypt -Total Downloads Latest Stable Version License +Total Downloads Latest Stable Version License Laravel/Lumen database encryption at database side using native AES_DECRYPT and AES_ENCRYPT functions. Automatically encrypt and decrypt fields in your Models. From dccf40267fb621c4f3f6a6d3afc7d618b74fcaa1 Mon Sep 17 00:00:00 2001 From: sandeep0108 <141115428+sandeep0108@users.noreply.github.com> Date: Thu, 4 Jan 2024 16:28:08 +0530 Subject: [PATCH 5/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d230088..d79df2b 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ php artisan make:command EncryptionForExistingData In this command you fetch existing table or model data without global scope `DecryptSelectScope`. -You can refer the example, clicking on below example button: +You can refer the example, clicking on below Example button: