mirror of
https://github.com/aler9/gortsplib
synced 2025-10-05 07:06:58 +08:00
18 lines
294 B
Go
18 lines
294 B
Go
package auth
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"encoding/hex"
|
|
)
|
|
|
|
// GenerateNonce generates a nonce that can be used in Validate().
|
|
func GenerateNonce() (string, error) {
|
|
byts := make([]byte, 16)
|
|
_, err := rand.Read(byts)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
return hex.EncodeToString(byts), nil
|
|
}
|