From 34c2d57e5be461efc7f53b8568009c18ab652a28 Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Fri, 11 Dec 2020 14:01:41 +0100 Subject: [PATCH] Add function for converting strings to color codes --- MD_STD.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/MD_STD.php b/MD_STD.php index 14451c3..69b475e 100644 --- a/MD_STD.php +++ b/MD_STD.php @@ -465,4 +465,18 @@ final class MD_STD { return \levenshtein($str1, $str2); } + + /** + * Converts a string to color codes. + * + * @param string $str Input string. + * + * @return string + */ + public static function string_to_color_code(string $str):string { + + $code = substr(dechex(crc32($str)), 0, 6); + return $code; + + } }