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
291 B
Go
Raw Normal View History

2023-06-07 18:46:19 +03:00
package randx
import (
"math/rand"
)
// String returns a random string with the given length
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)
}