Skip to content

Commit

Permalink
feat(user): change the hash way of gravatar
Browse files Browse the repository at this point in the history
  • Loading branch information
LinkinStars committed Jul 22, 2024
1 parent 0718884 commit f014602
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/gravatar/gravatar.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,18 @@
package gravatar

import (
"crypto/md5"
"crypto/sha256"
"encoding/hex"
"fmt"
"net/url"
"strings"
)

// GetAvatarURL get avatar url from gravatar by email
func GetAvatarURL(baseURL, email string) string {
h := md5.New()
h.Write([]byte(email))
return baseURL + hex.EncodeToString(h.Sum(nil))
hasher := sha256.Sum256([]byte(strings.TrimSpace(email)))
hash := hex.EncodeToString(hasher[:])
return baseURL + hash
}

// Resize resize avatar by pixel
Expand Down

0 comments on commit f014602

Please sign in to comment.