]> Raphaël G. Git Repositories - packbundle/commitdiff
Add array hashing
authorRaphaël Gertz <git@rapsys.eu>
Mon, 3 Oct 2022 00:39:10 +0000 (02:39 +0200)
committerRaphaël Gertz <git@rapsys.eu>
Mon, 3 Oct 2022 00:39:10 +0000 (02:39 +0200)
Util/SluggerUtil.php

index de8ce1bd93da6437e66f6e386704db9296052bec..8dc50df5ab8c592aff86043ada5b89cb0fbb8454 100644 (file)
@@ -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