MCPcopy
hub / github.com/perkeep/perkeep / RandToken

Function RandToken

pkg/auth/auth.go:484–490  ·  view source on GitHub ↗

RandToken genererates (with crypto/rand.Read) and returns a token that is the hex version (2x size) of size bytes of randomness.

(size int)

Source from the content-addressed store, hash-verified

482// RandToken genererates (with crypto/rand.Read) and returns a token
483// that is the hex version (2x size) of size bytes of randomness.
484func RandToken(size int) string {
485 buf := make([]byte, size)
486 if n, err := rand.Read(buf); err != nil || n != len(buf) {
487 panic("failed to get random: " + err.Error())
488 }
489 return fmt.Sprintf("%x", buf)
490}

Callers 2

NewHandlerFunction · 0.92
genProcessRandFunction · 0.85

Calls 2

ReadMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected