mirror of
https://github.com/dutchcoders/transfer.sh.git
synced 2025-01-07 09:50:18 +01:00
simplier and faster casting random symbols
This commit is contained in:
parent
ca5c89f130
commit
27c38e6a1e
1 changed files with 3 additions and 3 deletions
|
@ -37,14 +37,14 @@ const (
|
|||
|
||||
// generate a token
|
||||
func token(length int) string {
|
||||
result := ""
|
||||
result := make([]byte, length)
|
||||
for i := 0; i < length; i++ {
|
||||
x, err := rand.Int(rand.Reader, big.NewInt(int64(len(SYMBOLS))))
|
||||
if err != nil {
|
||||
log.Fatal("Failed to generate token")
|
||||
}
|
||||
result = string(SYMBOLS[x.Int64()]) + result
|
||||
result[i] = SYMBOLS[x.Int64()]
|
||||
}
|
||||
|
||||
return result
|
||||
return string(result)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue