1
0
mirror of https://github.com/oauth2-proxy/oauth2-proxy.git synced 2025-01-10 04:18:14 +02:00
oauth2-proxy/pkg/encryption/nonce.go

18 lines
275 B
Go
Raw Normal View History

2019-05-24 18:06:48 +02:00
package encryption
2017-03-28 03:14:38 +02:00
import (
"crypto/rand"
"fmt"
)
2018-11-29 16:26:41 +02:00
// Nonce generates a random 16 byte string to be used as a nonce
2017-03-28 03:14:38 +02: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
}