...

Source file src/github.com/okta/okta-jwt-verifier-golang/utils/nonce.go

Documentation: github.com/okta/okta-jwt-verifier-golang/utils

     1  package utils
     2  
     3  import (
     4  	"crypto/rand"
     5  	"encoding/base64"
     6  	"fmt"
     7  )
     8  
     9  // GenerateNonce generates a random base64 encoded string suitable for OpenID nonce
    10  func GenerateNonce() (string, error) {
    11  	nonceBytes := make([]byte, 32)
    12  	_, err := rand.Read(nonceBytes)
    13  	if err != nil {
    14  		return "", fmt.Errorf("could not generate nonce")
    15  	}
    16  
    17  	return base64.URLEncoding.EncodeToString(nonceBytes), nil
    18  }
    19  

View as plain text