Parameterize genString by length

This commit is contained in:
2020-04-01 00:25:01 -06:00
parent 9dfb70279f
commit e9e997c405
2 changed files with 8 additions and 6 deletions

View File

@ -220,11 +220,10 @@ const keyAdminCode = "admin_code"
var chars = []byte("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
func genString() (string, error) {
const length = 10
func genString(length int) (string, error) {
charsLength := big.NewInt(int64(len(chars)))
var maxN big.Int
maxN.Exp(charsLength, big.NewInt(length), nil)
maxN.Exp(charsLength, big.NewInt(int64(length)), nil)
n, err := rand.Int(rand.Reader, &maxN)
if err != nil {
return "", err