2fas-server/internal/common/crypto/prng.go
2022-12-31 10:22:38 +01:00

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
}