mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-13 23:44:52 +01:00
fix RNG
This commit is contained in:
@@ -5,18 +5,19 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
var RNG = NewRNG()
|
||||
|
||||
// Generate returns an alphanumeric token of specified length
|
||||
func Generate(length int) string {
|
||||
rng := RNG()
|
||||
var chars = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
|
||||
b := make([]rune, length)
|
||||
for i := range b {
|
||||
b[i] = chars[rng.Intn(len(chars))]
|
||||
b[i] = chars[RNG.Intn(len(chars))]
|
||||
}
|
||||
return string(b)
|
||||
}
|
||||
|
||||
// RNG returns a new RNG generator
|
||||
func RNG() *rand.Rand {
|
||||
// NewRNG returns a new NewRNG generator
|
||||
func NewRNG() *rand.Rand {
|
||||
return rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user