github.com/safedep/dry@v0.0.0-20241016050132-a15651f0548b/utils/rand.go (about) 1 package utils 2 3 import ( 4 "crypto/rand" 5 "log" 6 "math/big" 7 ) 8 9 // Int64 returns a cryptographically secure 64 bit random number 10 func Int64(max int64) int64 { 11 return randSource(max).Int64() 12 } 13 14 func randSource(max int64) *big.Int { 15 n, err := rand.Int(rand.Reader, big.NewInt(max)) 16 if err != nil { 17 log.Fatalf("rand generator: %v", err) 18 } 19 20 return n 21 }