aboutsummaryrefslogtreecommitdiffstats
path: root/common/utils.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2019-01-18 19:10:55 +0800
committerGitHub <noreply@github.com>2019-01-18 19:10:55 +0800
commit632fa7914a2e6dbf1812581e0e769c93189771ca (patch)
treee8b415b01de87a6457a65ba191dc90f3ab8565e0 /common/utils.go
parent9ff8f0cdc45a7b294ae71a28e7e205bb67e559cb (diff)
downloaddexon-consensus-632fa7914a2e6dbf1812581e0e769c93189771ca.tar.gz
dexon-consensus-632fa7914a2e6dbf1812581e0e769c93189771ca.tar.zst
dexon-consensus-632fa7914a2e6dbf1812581e0e769c93189771ca.zip
misc: Add gosec to check security issues (#424)
* Add gosec to tools * Run security check to ci * Fix secrity issues
Diffstat (limited to 'common/utils.go')
-rw-r--r--common/utils.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/common/utils.go b/common/utils.go
index 7e89c05..63d25a3 100644
--- a/common/utils.go
+++ b/common/utils.go
@@ -2,13 +2,20 @@ package common
import (
"math/rand"
+ "time"
)
+var random *rand.Rand
+
+func init() {
+ random = rand.New(rand.NewSource(time.Now().Unix()))
+}
+
// NewRandomHash returns a random Hash-like value.
func NewRandomHash() Hash {
x := Hash{}
for i := 0; i < HashLength; i++ {
- x[i] = byte(rand.Int() % 256)
+ x[i] = byte(random.Int() % 256)
}
return x
}