From 3ad42d9279a49ba6ac5495b0127421f076e654fc Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Mon, 9 May 2016 09:36:42 +0000 Subject: [PATCH] lib/util: Should seed random number generator on startup GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3063 --- lib/util/random.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/util/random.go b/lib/util/random.go index fe77ecf4..8b6c485f 100644 --- a/lib/util/random.go +++ b/lib/util/random.go @@ -17,6 +17,11 @@ import ( // randomCharset contains the characters that can make up a randomString(). const randomCharset = "01234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-" +func init() { + // The default RNG should be seeded with something good. + mathRand.Seed(RandomInt64()) +} + // RandomString returns a string of random characters (taken from // randomCharset) of the specified length. func RandomString(l int) string {