From ecaff8f986a9dae878c1b5e710e1c9920c0504d4 Mon Sep 17 00:00:00 2001 From: Tapan Date: Wed, 29 May 2024 14:43:40 +0530 Subject: [PATCH] bug fix: wrong encrypt/decrypt key for validation --- src/Traits/ValidatesEncrypted.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Traits/ValidatesEncrypted.php b/src/Traits/ValidatesEncrypted.php index a207003..5055dce 100644 --- a/src/Traits/ValidatesEncrypted.php +++ b/src/Traits/ValidatesEncrypted.php @@ -27,7 +27,7 @@ public function addValidators() $field = isset($parameters[1]) ? $parameters[1] : $attribute; $ignore = isset($parameters[2]) ? $parameters[2] : null; - $items = DB::select("SELECT count(*) as aggregate FROM `" . $parameters[0] . "` WHERE AES_DECRYPT(`" . $field . "`, '" . config("app.key") . "') LIKE '" . $value . "' COLLATE utf8mb4_general_ci" . ($ignore ? " AND id != " . $ignore : '')); + $items = DB::select("SELECT count(*) as aggregate FROM `" . $parameters[0] . "` WHERE AES_DECRYPT(`" . $field . "`, '" . config("mysql-encrypt.key") . "') LIKE '" . $value . "' COLLATE utf8mb4_general_ci" . ($ignore ? " AND id != " . $ignore : '')); return $items[0]->aggregate == 0; }); @@ -40,7 +40,7 @@ public function addValidators() $field = isset($parameters[1]) ? $parameters[1] : $attribute; - $items = DB::select("SELECT count(*) as aggregate FROM `" . $parameters[0] . "` WHERE AES_DECRYPT(`" . $field . "`, '" . config("app.key") . "') LIKE '" . $value . "' COLLATE utf8mb4_general_ci"); + $items = DB::select("SELECT count(*) as aggregate FROM `" . $parameters[0] . "` WHERE AES_DECRYPT(`" . $field . "`, '" . config("mysql-encrypt.key") . "') LIKE '" . $value . "' COLLATE utf8mb4_general_ci"); return $items[0]->aggregate > 0; });