init pseudorandom seed
This commit is contained in:
@@ -4,10 +4,15 @@ import (
|
|||||||
cryptoRand "crypto/rand"
|
cryptoRand "crypto/rand"
|
||||||
"math/big"
|
"math/big"
|
||||||
mathRand "math/rand"
|
mathRand "math/rand"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const defaultRandomAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
const defaultRandomAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
mathRand.Seed(time.Now().UnixNano())
|
||||||
|
}
|
||||||
|
|
||||||
// RandomString generates a cryptographically random string with the specified length.
|
// RandomString generates a cryptographically random string with the specified length.
|
||||||
//
|
//
|
||||||
// The generated string matches [A-Za-z0-9]+ and it's transparent to URL-encoding.
|
// The generated string matches [A-Za-z0-9]+ and it's transparent to URL-encoding.
|
||||||
|
|||||||
Reference in New Issue
Block a user