1
0
mirror of https://github.com/lus/pasty.git synced 2023-08-10 21:13:09 +03:00
pasty/internal/randx/string.go

15 lines
294 B
Go
Raw Normal View History

2023-06-07 18:46:19 +03:00
package randx
import (
"math/rand"
)
2023-06-07 19:25:28 +03:00
// String generates a random string with the given length.
2023-06-07 18:46:19 +03:00
func String(characters string, length int) string {
bytes := make([]byte, length)
for i := range bytes {
bytes[i] = characters[rand.Int63()%int64(len(characters))]
}
return string(bytes)
}