Explorar el Código

Merge pull request #311 from cheeseandcereal/crypto_seed

use cryptographically secure rng seed
tags/v1.2.0
Andrea Spacca hace 4 años
committed by GitHub
padre
commit
a26b32dd86
No se encontró ninguna clave conocida en la base de datos para esta firma ID de clave GPG: 4AEE18F83AFDEB23
Se han modificado 1 ficheros con 7 adiciones y 1 borrados
  1. +7
    -1
      server/server.go

+ 7
- 1
server/server.go Ver fichero

@@ -28,6 +28,8 @@ import (
"errors"
gorillaHandlers "github.com/gorilla/handlers"
"log"
crypto_rand "crypto/rand"
"encoding/binary"
"math/rand"
"mime"
"net/http"
@@ -306,7 +308,11 @@ func New(options ...OptionFn) (*Server, error) {
}

func init() {
rand.Seed(time.Now().UTC().UnixNano())
var seedBytes [8]byte
if _, err := crypto_rand.Read(seedBytes[:]); err != nil {
panic("cannot obtain cryptographically secure seed")
}
rand.Seed(int64(binary.LittleEndian.Uint64(seedBytes[:])))
}

func (s *Server) Run() {


Cargando…
Cancelar
Guardar