feat: begin working on the categorize

This commit is contained in:
DaanSelen
2026-04-23 16:57:58 +02:00
parent 417cecf43f
commit 24be1cedeb
6 changed files with 50 additions and 43 deletions
+16
View File
@@ -1,9 +1,25 @@
package utility
import (
"crypto/sha512"
"encoding/hex"
"io"
"github.com/google/uuid"
)
func GenerateHashFromReader(r io.Reader) (string, error) {
h := sha512.New()
if _, err := io.Copy(h, r); err != nil {
return "", err
}
// return the sha checksum in hex
return hex.EncodeToString(h.Sum(nil)), nil
// alternatively return in base64
//return base64.StdEncoding.EncodeToString(h.Sum(nil)), nil
}
func GenerateSafeName(category MediaType, ext string) string {
return uuid.New().String() + "_" + string(category) + ext
}