Bytes generates a random byte slice of length n.
(n int)
| 33 | |
| 34 | // Bytes generates a random byte slice of length n. |
| 35 | func Bytes(n int) []byte { |
| 36 | p := make([]byte, n) |
| 37 | _, err := rand.Read(p) |
| 38 | if err != nil { |
| 39 | panic(err) |
| 40 | } |
| 41 | return p |
| 42 | } |
| 43 | |
| 44 | // String returns a random string of length n, it uses the characters of base64.URLEncoding. |
| 45 | func String(n int) string { |