Files
WarpBox/lib/helpers/ids.go
Daniel Legt 2f37958c31 refactor(server): use boxstore helpers and file status consts
- Move box ID validation, file listing/pathing, manifest creation, and uploads to `boxstore`
- Use shared helpers for safe filenames and polling interval env parsing
- Add file status constants to `models` to avoid duplicated magic strings across handlersrefactor(server): use boxstore helpers and file status consts

- Move box ID validation, file listing/pathing, manifest creation, and uploads to `boxstore`
- Use shared helpers for safe filenames and polling interval env parsing
- Add file status constants to `models` to avoid duplicated magic strings across handlers
2026-04-27 18:01:02 +03:00

31 lines
497 B
Go

package helpers
import (
"crypto/rand"
"encoding/hex"
"strings"
)
func RandomHexID(byteCount int) (string, error) {
bytes := make([]byte, byteCount)
if _, err := rand.Read(bytes); err != nil {
return "", err
}
return hex.EncodeToString(bytes), nil
}
func ValidLowerHexID(value string, length int) bool {
if len(value) != length {
return false
}
for _, character := range value {
if !strings.ContainsRune("0123456789abcdef", character) {
return false
}
}
return true
}