github.com/quickfeed/quickfeed@v0.0.0-20240507093252-ed8ca812a09c/internal/rand/rand.go (about)

     1  package rand
     2  
     3  import (
     4  	"crypto/rand"
     5  	"crypto/sha256"
     6  	"fmt"
     7  )
     8  
     9  func String() string {
    10  	randomness := make([]byte, 10)
    11  	if _, err := rand.Read(randomness); err != nil {
    12  		panic("couldn't generate randomness")
    13  	}
    14  	return fmt.Sprintf("%x", sha256.Sum256(randomness))
    15  }