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)
| 48 | // |
| 49 | // For a cryptographically random (but a little bit slower) use RandomStringWithAlphabet instead. |
| 50 | func 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 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…