feat(auth): add auth hash (allows purging sessions & more)
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-01-27 21:02:08 -05:00
parent 9792a6ff19
commit 015ca30ac5
14 changed files with 316 additions and 68 deletions

View File

@@ -3,6 +3,7 @@ package utils
import (
"bytes"
"crypto/md5"
"crypto/rand"
"fmt"
"io"
"os"
@@ -42,3 +43,13 @@ func CalculatePartialMD5(filePath string) (string, error) {
allBytes := buf.Bytes()
return fmt.Sprintf("%x", md5.Sum(allBytes)), nil
}
// Creates a token of n size
func GenerateToken(n int) ([]byte, error) {
b := make([]byte, n)
_, err := rand.Read(b)
if err != nil {
return nil, err
}
return b, nil
}