mirror of
https://github.com/twofas/2fas-server.git
synced 2024-12-12 12:09:56 +01:00
20 lines
295 B
Go
20 lines
295 B
Go
package crypto
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"encoding/hex"
|
|
)
|
|
|
|
func GenerateNonce() (string, error) {
|
|
bytes := make([]byte, 32)
|
|
|
|
_, err := rand.Read(bytes)
|
|
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
return hex.EncodeToString(bytes), nil
|
|
//return base64.URLEncoding.EncodeToString(nonceBytes), nil
|
|
}
|