NewRandomString returns a random string of the given length. The resulting entropy will be (5 * length) bits.
(length int)
| 401 | // NewRandomString returns a random string of the given length. |
| 402 | // The resulting entropy will be (5 * length) bits. |
| 403 | func 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. |
searching dependent graphs…