package utils

import (
	"math/rand"
	"strings"
)

const (
	charset        = "abcdefghijklmnopqrstuvwxyz0123456789"
	charsetNumbers = "0123456789"
)

// RandomString generates a random string of length n based on self defined charset
func RandomString(length int) string {
	sb := strings.Builder{}
	sb.Grow(length)
	for i := 0; i < length; i++ {
		sb.WriteByte(charset[rand.Intn(len(charset))])
	}
	return sb.String()
}

// RandomStringNumbers
func RandomStringNumbers(length int) string {
	sb := strings.Builder{}
	sb.Grow(length)
	for range length {
		sb.WriteByte(charsetNumbers[rand.Intn(len(charsetNumbers))])
	}

	return sb.String()
}
