getRandomBytes generates a cryptographically secure pseudorandom numbers of the given size in byte
(numBytes int)
| 25 | // getRandomBytes generates a cryptographically secure pseudorandom numbers of the |
| 26 | // given size in byte |
| 27 | func getRandomBytes(numBytes int) ([]byte, error) { |
| 28 | b := make([]byte, numBytes) |
| 29 | if _, err := rand.Read(b); err != nil { |
| 30 | return nil, errors.Wrap(err, "reading random bits") |
| 31 | } |
| 32 | |
| 33 | return b, nil |
| 34 | } |
| 35 | |
| 36 | // GetRandomStr generates a cryptographically secure pseudorandom numbers of the |
| 37 | // given size in byte |