MCPcopy
hub / github.com/mattermost/mattermost / NewRandomString

Function NewRandomString

server/public/model/utils.go:403–407  ·  view source on GitHub ↗

NewRandomString returns a random string of the given length. The resulting entropy will be (5 * length) bits.

(length int)

Source from the content-addressed store, hash-verified

401// NewRandomString returns a random string of the given length.
402// The resulting entropy will be (5 * length) bits.
403func NewRandomString(length int) string {
404 data := make([]byte, 1+(length*5/8))
405 rand.Read(data)
406 return encoding.EncodeToString(data)[:length]
407}
408
409// NewTestPassword generates a password that meets complexity requirements
410// (uppercase, lowercase, number, special character) with a minimum length of 14.

Callers 5

TestRandomStringFunction · 0.85
TestAccessIsValidFunction · 0.85
TestAuthIsValidFunction · 0.85
NewTokenFunction · 0.85

Calls 1

ReadMethod · 0.65

Tested by 4

TestRandomStringFunction · 0.68
TestAccessIsValidFunction · 0.68
TestAuthIsValidFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…