This commit is contained in:
Marcus Efraimsson
2019-01-15 11:11:32 +01:00
parent d907b1ec6b
commit e08f61059b
3 changed files with 49 additions and 0 deletions

View File

@ -101,3 +101,11 @@ func DecodeBasicAuthHeader(header string) (string, string, error) {
return userAndPass[0], userAndPass[1], nil
}
func RandomHex(n int) (string, error) {
bytes := make([]byte, n)
if _, err := rand.Read(bytes); err != nil {
return "", err
}
return hex.EncodeToString(bytes), nil
}