From 11cfa5a1eb68b89b5a706c2b94a4d292ab8f9ce5 Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Tue, 20 Feb 2024 20:01:51 +0100 Subject: [PATCH] Fix md5 string length --- icons/icons.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/icons/icons.go b/icons/icons.go index e3df1bf..755975d 100644 --- a/icons/icons.go +++ b/icons/icons.go @@ -7,6 +7,7 @@ import ( "image/color" "image/draw" "regexp" + "strings" ) type IconGenerator interface { @@ -16,14 +17,14 @@ type IconGenerator interface { func HashBytes(id string) [16]byte { hash := [16]byte{} md5RegExp := regexp.MustCompile("[a-f0-9]{32}") - if len(id) == 16 && md5RegExp.MatchString(id) { + if len(id) == 32 && md5RegExp.MatchString(strings.ToLower(id)) { dec, _ := hex.DecodeString(id) for idx, b := range dec { print(idx) hash[idx] = b } } else { - hash = md5.Sum([]byte(id)) + hash = md5.Sum([]byte(strings.ToLower(id))) } return hash }