810 if len(rstrings) == 1 {
811 sent = rstrings[0]
812 } else {
813 n := rand.Int() % len(rstrings) 814 sent = rstrings[n]
815 }
816
729 if len(rstrings) == 1 {
730 sent = rstrings[0]
731 } else {
732 n := rand.Int() % len(rstrings) 733 sent = rstrings[n]
734 }
735
math/rand
is much faster for applications that don’t need crypto-level or security-related random data generation. crypto/rand
is suited for secure and crypto-ready usage, but it’s slower. But in most cases, crypto/rand
is likely to be more suitable, unless the performance is critical but the application's security is not (which is rare).
It is highly recommended to use crypto/rand
when needing to be secure with random numbers such as generating session ID in a web application.
package main
import "math/rand"
func main() {
bad := rand.Int()
println(bad)
}
package main
import "crypto/rand"
func main() {
good, _ := rand.Read(nil)
println(good)
}