photoprism/pkg/rnd/uid.go
Michael Mayer 323d495840 Auth: Apply user rights and permissions in the search API #98 #782
Signed-off-by: Michael Mayer <michael@photoprism.app>
2022-09-30 00:42:19 +02:00

21 lines
417 B
Go

package rnd
import (
"strconv"
"time"
)
const (
PrefixNone = byte(0)
PrefixMixed = byte('*')
)
// GenerateUID returns a unique id with prefix as string.
func GenerateUID(prefix byte) string {
result := make([]byte, 0, 16)
result = append(result, prefix)
result = append(result, strconv.FormatInt(time.Now().UTC().Unix(), 36)[0:6]...)
result = append(result, GenerateToken(9)...)
return string(result)
}