Go 1.22 improves the security of programs by using the ChaCha8Rand generator for random numbers. The previous Go 1 generator had predictable outputs and could lead to serious security issues. ChaCha8Rand provides better randomness and is more suitable for generating random numbers. It is used in math/rand/v2 package, as well as in the math/rand and runtime packages of the Go standard library. The performance of ChaCha8Rand is comparable to the Go 1 generator and PCG generator.

14m read timeFrom go.dev
Post cover image
Table of contents
The Go BlogSecure Randomness in Go 1.22

Sort: