From 0ebfc3b99db9bb11239e673cfb532e2afbc150b4 Mon Sep 17 00:00:00 2001 From: krustowski Date: Tue, 16 Jul 2024 09:10:12 +0200 Subject: [PATCH] fix hashing alg for gravatar avatar fetching --- .env.example | 2 +- api/swagger.json | 2 +- pkg/backend/db/migration.go | 16 +++++++++++----- pkg/backend/router.go | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.env.example b/.env.example index f3bae05c..7d43a44c 100644 --- a/.env.example +++ b/.env.example @@ -3,5 +3,5 @@ # APP_NAME=litter-go -APP_VERSION=0.35.11 +APP_VERSION=0.35.12 GOLANG_VERSION=1.22 diff --git a/api/swagger.json b/api/swagger.json index e7cb1f1b..e6e6ff87 100644 --- a/api/swagger.json +++ b/api/swagger.json @@ -13,7 +13,7 @@ "name": "MIT", "url": "https://github.com/krustowski/litter-go/blob/master/LICENSE" }, - "version": "0.35.11" + "version": "0.35.12" }, "host": "littr.n0p.cz", "basePath": "/api/v1", diff --git a/pkg/backend/db/migration.go b/pkg/backend/db/migration.go index 9afa7b7f..61161e01 100644 --- a/pkg/backend/db/migration.go +++ b/pkg/backend/db/migration.go @@ -1,8 +1,9 @@ package db import ( - "crypto/md5" - "encoding/hex" + "crypto/sha256" + //"encoding/hex" + "fmt" "net/http" "strconv" "strings" @@ -183,10 +184,15 @@ func GetGravatarURL(emailInput string, channel chan string) string { email := strings.ToLower(emailInput) size := 150 + sha := sha256.New() + sha.Write([]byte(email)) + + hashedStringEmail := fmt.Sprintf("%x", sha.Sum(nil)) + // hash the emailInput - byteEmail := []byte(email) - hashEmail := md5.Sum(byteEmail) - hashedStringEmail := hex.EncodeToString(hashEmail[:]) + //byteEmail := []byte(email) + //hashEmail := md5.Sum(byteEmail) + //hashedStringEmail := hex.EncodeToString(hashEmail[:]) url := "https://www.gravatar.com/avatar/" + hashedStringEmail + "&s=" + strconv.Itoa(size) diff --git a/pkg/backend/router.go b/pkg/backend/router.go index 815d8ff1..4d96ad0f 100644 --- a/pkg/backend/router.go +++ b/pkg/backend/router.go @@ -1,5 +1,5 @@ // @title litter-go -// @version 0.35.11 +// @version 0.35.12 // @description nanoblogging platform as PWA built on go-app framework // @termsOfService https://littr.eu/tos