lib/util: Should seed random number generator on startup
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3063
This commit is contained in:
committed by
Audrius Butkevicius
parent
bd41e21c26
commit
3ad42d9279
@@ -17,6 +17,11 @@ import (
|
|||||||
// randomCharset contains the characters that can make up a randomString().
|
// randomCharset contains the characters that can make up a randomString().
|
||||||
const randomCharset = "01234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-"
|
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
|
// RandomString returns a string of random characters (taken from
|
||||||
// randomCharset) of the specified length.
|
// randomCharset) of the specified length.
|
||||||
func RandomString(l int) string {
|
func RandomString(l int) string {
|
||||||
|
|||||||
Reference in New Issue
Block a user