package utils

import (
	"math/rand"
	"time"
)

// seededRand is a source of random numbers seeded with the current time.
var seededRand *rand.Rand = rand.New(rand.NewSource(time.Now().UnixNano()))

// randomString generates a random string of the specified length using the given charset.
func RandomString(length int, charset string) string {
	b := make([]byte, length)
	for i := range b {
		b[i] = charset[seededRand.Intn(len(charset))]
	}
	return string(b)
}