Skip to content

Commit

Permalink
bug fix: wrong encrypt/decrypt key for validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Tapan-Tops committed May 29, 2024
1 parent bd3e51f commit ecaff8f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Traits/ValidatesEncrypted.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand All @@ -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;
});
Expand Down

0 comments on commit ecaff8f

Please sign in to comment.