MCPcopy
hub / github.com/pocketbase/pocketbase / PseudorandomStringWithAlphabet

Function PseudorandomStringWithAlphabet

tools/security/random.go:50–59  ·  view source on GitHub ↗

PseudorandomStringWithAlphabet generates a pseudorandom string with the specified length and characters set. For a cryptographically random (but a little bit slower) use RandomStringWithAlphabet instead.

(length int, alphabet string)

Source from the content-addressed store, hash-verified

48//
49// For a cryptographically random (but a little bit slower) use RandomStringWithAlphabet instead.
50func PseudorandomStringWithAlphabet(length int, alphabet string) string {
51 b := make([]byte, length)
52 max := len(alphabet)
53
54 for i := range b {
55 b[i] = alphabet[mathRand.IntN(max)]
56 }
57
58 return string(b)
59}

Callers 3

GenerateDefaultRandomIdFunction · 0.92
fieldIndexNameMethod · 0.92
PseudorandomStringFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…