Skip to content

Commit

Permalink
fix: RandStr not random enough with time.Now as seed
Browse files Browse the repository at this point in the history
  • Loading branch information
jm33-m0 committed Mar 30, 2022
1 parent 70c0f5e commit e3aed62
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/lib/util/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ func RandInt(min, max int) int {
// RandStr random string
func RandStr(n int) string {
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
mathRand.Seed(time.Now().Unix())
mathRand.Seed(int64(RandInt(0xff, 0xffffffff)))
b := make([]rune, n)
for i := range b {
b[i] = letters[mathRand.Intn(len(letters))]
b[i] = letters[int64(RandInt(0, len(letters)))]
}
return string(b)
}
Expand Down

0 comments on commit e3aed62

Please sign in to comment.