github.com/qioalice/ekago/v3@v3.3.2-0.20221202205325-5c262d586ee4/ekarand/init.go (about)

     1  // Copyright © 2020-2021. All rights reserved.
     2  // Author: Ilya Stroy.
     3  // Contacts: iyuryevich@pm.me, https://github.com/qioalice
     4  // License: https://opensource.org/licenses/MIT
     5  
     6  package ekarand
     7  
     8  import (
     9  	crand "crypto/rand"
    10  	mrand "math/rand"
    11  
    12  	"encoding/binary"
    13  	"time"
    14  )
    15  
    16  func init() {
    17  
    18  	var crEntropy [8]byte
    19  	_, _ = crand.Read(crEntropy[:])
    20  
    21  	d := int64(binary.BigEndian.Uint64(crEntropy[:]))
    22  	mrand.Seed(time.Now().UnixNano() + d)
    23  }