From 2fa9d589ff1c67df6e2f66ea95d66fd581ed258e Mon Sep 17 00:00:00 2001 From: Marco Nett Date: Fri, 24 Mar 2023 11:57:04 +0100 Subject: [PATCH] convertStringToHash --- src/Thumbhash.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Thumbhash.php b/src/Thumbhash.php index 60d7b57..c46f01e 100644 --- a/src/Thumbhash.php +++ b/src/Thumbhash.php @@ -140,6 +140,10 @@ public static function convertHashToString(array $hash): string return rtrim(base64_encode(implode(array_map("chr", $hash))), '='); } + public static function convertStringToHash(string $str): array + { + return array_map("ord", str_split(base64_decode($str . "="))); + } /** * Decodes a ThumbHash to an RGBA image. RGB is not premultiplied by A.