mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2024-11-24 08:52:25 +02:00
18 lines
275 B
Go
18 lines
275 B
Go
package encryption
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"fmt"
|
|
)
|
|
|
|
// Nonce generates a random 16 byte string to be used as a nonce
|
|
func Nonce() (nonce string, err error) {
|
|
b := make([]byte, 16)
|
|
_, err = rand.Read(b)
|
|
if err != nil {
|
|
return
|
|
}
|
|
nonce = fmt.Sprintf("%x", b)
|
|
return
|
|
}
|