mirror of
https://github.com/dutchcoders/transfer.sh.git
synced 2025-01-08 10:10:19 +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
|
// generate a token
|
||||||
func token(length int) string {
|
func token(length int) string {
|
||||||
result := ""
|
result := make([]byte, length)
|
||||||
for i := 0; i < length; i++ {
|
for i := 0; i < length; i++ {
|
||||||
x, err := rand.Int(rand.Reader, big.NewInt(int64(len(SYMBOLS))))
|
x, err := rand.Int(rand.Reader, big.NewInt(int64(len(SYMBOLS))))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("Failed to generate token")
|
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