mirror of
https://github.com/pcvolkmer/idicon.git
synced 2025-04-19 16:46:50 +00:00
Fix md5 string length
Some checks failed
Deploy / build (push) Failing after 10m4s
Some checks failed
Deploy / build (push) Failing after 10m4s
This commit is contained in:
parent
8e5ca646d0
commit
11cfa5a1eb
@ -7,6 +7,7 @@ import (
|
|||||||
"image/color"
|
"image/color"
|
||||||
"image/draw"
|
"image/draw"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type IconGenerator interface {
|
type IconGenerator interface {
|
||||||
@ -16,14 +17,14 @@ type IconGenerator interface {
|
|||||||
func HashBytes(id string) [16]byte {
|
func HashBytes(id string) [16]byte {
|
||||||
hash := [16]byte{}
|
hash := [16]byte{}
|
||||||
md5RegExp := regexp.MustCompile("[a-f0-9]{32}")
|
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)
|
dec, _ := hex.DecodeString(id)
|
||||||
for idx, b := range dec {
|
for idx, b := range dec {
|
||||||
print(idx)
|
print(idx)
|
||||||
hash[idx] = b
|
hash[idx] = b
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
hash = md5.Sum([]byte(id))
|
hash = md5.Sum([]byte(strings.ToLower(id)))
|
||||||
}
|
}
|
||||||
return hash
|
return hash
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user