oauth2_proxy/cookie/nonce.go

18 lines
271 B
Go
Raw Permalink Normal View History

2017-03-28 01:14:38 +00:00
package cookie
import (
"crypto/rand"
"fmt"
)
2018-11-29 14:26:41 +00:00
// Nonce generates a random 16 byte string to be used as a nonce
2017-03-28 01:14:38 +00:00
func Nonce() (nonce string, err error) {
b := make([]byte, 16)
_, err = rand.Read(b)
if err != nil {
return
}
nonce = fmt.Sprintf("%x", b)
return
}