yt-gen-app/lib/random-hex.go
2023-06-23 14:54:47 +03:00

15 lines
228 B
Go

package lib
import (
"crypto/rand"
"encoding/hex"
)
func RandomHex(n int) (string, error) {
bytes := make([]byte, n)
if _, err := rand.Read(bytes); err != nil {
return "", err
}
return hex.EncodeToString(bytes), nil
}