From 9d0a8f506d7b005236a693838ffefc655df2e39f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Mon, 3 Oct 2022 02:39:10 +0200 Subject: [PATCH] Add array hashing --- Util/SluggerUtil.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Util/SluggerUtil.php b/Util/SluggerUtil.php index de8ce1b..8dc50df 100644 --- a/Util/SluggerUtil.php +++ b/Util/SluggerUtil.php @@ -118,10 +118,16 @@ class SluggerUtil { /** * Crypt and base64uri encode string * - * @param string $data The data string + * @param array|string $data The data string * @return string The hashed data */ - public function hash(string $data): string { + public function hash(array|string $data): string { + //With array + if (is_array($data)) { + //Json encode array + $data = json_encode($data); + } + //Return hashed data //XXX: we use hash_hmac with md5 hash //XXX: crypt was dropped because it provided identical signature for string starting with same pattern -- 2.41.1