Bytes generates random bytes with length n.
(n int)
| 10 | |
| 11 | // Bytes generates random bytes with length n. |
| 12 | func Bytes(n int) []byte { |
| 13 | b := make([]byte, n) |
| 14 | _, err := rand.Reader.Read(b) |
| 15 | if err != nil { |
| 16 | panic(fmt.Sprintf("failed to generate rand bytes: %v", err)) |
| 17 | } |
| 18 | return b |
| 19 | } |
| 20 | |
| 21 | // String generates a random string with length n. |
| 22 | func String(n int) string { |