2020-01-12 14:00:56 +01:00
|
|
|
package rnd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strconv"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
// PPID returns a unique id with prefix as string.
|
2020-05-01 12:57:26 +02:00
|
|
|
func PPID(prefix byte) string {
|
2020-01-23 09:50:43 +01:00
|
|
|
result := make([]byte, 0, 16)
|
2020-05-01 12:57:26 +02:00
|
|
|
result = append(result, prefix)
|
2020-01-12 14:00:56 +01:00
|
|
|
result = append(result, strconv.FormatInt(time.Now().UTC().Unix(), 36)[0:6]...)
|
2020-01-23 09:50:43 +01:00
|
|
|
result = append(result, Token(9)...)
|
2020-01-12 14:00:56 +01:00
|
|
|
|
|
|
|
return string(result)
|
|
|
|
}
|
2020-05-01 12:57:26 +02:00
|
|
|
|
|
|
|
// IsPPID returns true if the id seems to be a PhotoPrism unique id.
|
|
|
|
func IsPPID(id string, prefix byte) bool {
|
|
|
|
if len(id) != 16 {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
return id[0] == prefix
|
|
|
|
}
|