Generating Secure Random Numbers

Let’s learn about secure random number generation in Go.

We'll cover the following

If we intend to use these pseudorandom numbers for security-related work, it is important that we use the crypto/rand package, which implements a cryptographically secure pseudorandom number generator. We do not need to define a seed when using the crypto/rand package.

Coding example

The following function, which is part of the cryptoRand.go source code, showcases how secure random numbers are generated with the functionality of crypto/rand.

Get hands-on with 1400+ tech skills courses.