utils/generators.go

41 lines
722 B
Go
Raw Normal View History

2023-10-02 23:42:16 +02:00
package utils
import (
"crypto/rand"
"fmt"
"strconv"
"strings"
"time"
"github.com/google/uuid"
)
// GenerateNewSHA256Sum returns a fresh SHA256Sum
func GenerateNewSHA256Sum() string {
timestamp := strconv.FormatInt(time.Now().Unix(), 10)
prime, _ := rand.Prime(rand.Reader, 512)
data := []string{fmt.Sprintf("%d", prime)}
for i := 0; i < 64; i++ {
prime, _ = rand.Prime(rand.Reader, 64)
data = append(
data,
strings.Join(
[]string{
fmt.Sprintf("%d", prime),
GenerateNewUUID(),
2023-10-03 14:46:03 +02:00
timestamp,
},
2023-10-02 23:42:16 +02:00
"|",
),
)
}
return GetSHA256SumOfString(strings.Join(data, "|||"))
}
// GenerateNewUUID returns a fresh UUID
func GenerateNewUUID() string {
return uuid.New().String()
}