Files
gotenberg/internal/pkg/rand/rand.go
Julien Neuhart 495203c112 v3.0.0 (#18)
2018-12-10 16:09:19 +01:00

18 lines
312 B
Go

package rand
import (
"crypto/rand"
"encoding/hex"
"fmt"
)
// Get returns a random string.
func Get() (string, error) {
randBytes := make([]byte, 16)
_, err := rand.Read(randBytes)
if err != nil {
return "", fmt.Errorf("creating random string: %v", err)
}
return hex.EncodeToString(randBytes), nil
}