Random Generators

Overview

This page contains recommendations for generating random values.

General

  • Use only cryptographically strong random generators to produce random values, see the Cryptographically strong random generators section.

  • Do not use standard pseudo-random number generators, such as those used in mathematics to generate pseudo-random numbers.

Clarification

Standard pseudo-random number generators can not withstand cryptographic attacks because such generators are based on functions that produce predictable values.

  • Make sure the seed that is used to initialize a generator has enough entropy.

  • Periodically reinitialize seeds.

Cryptographically strong random generators

Use the crypto/rand package to generate cryptographically strong random values in Go.

Last updated