func (r *Random) RandomString(n int) string {
	d := r.encoding.DecodedLen(n)
	buf := make([]byte, n)
	r.encoding.Encode(buf, RandomBytes(d))
	for k, v := range buf {
		if v == 0x00 {
			buf[k] = r.substitute[mrand.Intn(r.substituteLen)]
		}
	}
	return BytesToString(buf)
}
RandomString returns a base64 encoded securely generated
random string. It will panic if the system's secure random number generator
fails to function correctly.
The length n must be an integer multiple of 4, otherwise the last character will be padded with `=`.
package goutil
import (
	"bytes"
	"crypto/rand"
	"encoding/base64"
	mrand "math/rand"
)
func NewRandom(alphabet string) *Random {
	r := new(Random)
	diff := 64 - len(alphabet)
	if diff < 0 {
		r.substitute = []byte(alphabet[64:])
		r.substituteLen = len(r.substitute)
		alphabet = alphabet[:64]
	} else {
		r.substitute = []byte(alphabet)
		r.substituteLen = len(r.substitute)
		if diff > 0 {
			alphabet += string(bytes.Repeat([]byte{0x00}, diff))
		}
	}
	r.encoding = base64.NewEncoding(alphabet).WithPadding(base64.NoPadding)
	return r
}
type Random struct {
	encoding      *base64.Encoding
	substitute    []byte
	substituteLen int
}