This commit is contained in:
Pavel Flegr 2026-04-08 17:53:30 +02:00
commit ef105e1cac
22 changed files with 3001 additions and 0 deletions

25
internal/platform/id.go Normal file
View file

@ -0,0 +1,25 @@
package platform
import (
"crypto/rand"
"encoding/hex"
"fmt"
)
func NewID() (string, error) {
buf := make([]byte, 16)
if _, err := rand.Read(buf); err != nil {
return "", fmt.Errorf("read random id bytes: %w", err)
}
return hex.EncodeToString(buf), nil
}
func NewToken() (string, error) {
buf := make([]byte, 32)
if _, err := rand.Read(buf); err != nil {
return "", fmt.Errorf("read random token bytes: %w", err)
}
return hex.EncodeToString(buf), nil
}