superbanka/internal/platform/id.go
Pavel Flegr ef105e1cac init
2026-04-08 17:53:30 +02:00

25 lines
473 B
Go

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
}