Make sure there are at least 2 chars in charset.

This commit is contained in:
Dmitry Chestnykh 2015-04-04 00:45:19 +02:00
parent d7c89a5f19
commit 46cf8faafd

View File

@ -54,8 +54,8 @@ func NewLenChars(length int, chars []byte) string {
return "" return ""
} }
clen := len(chars) clen := len(chars)
if clen > 256 { if clen < 2 || clen > 256 {
panic("uniuri: maximum length of charset for NewLenChars is 256") panic("uniuri: wrong charset length for NewLenChars")
} }
maxrb := 255 - (256 % clen) maxrb := 255 - (256 % clen)
b := make([]byte, length) b := make([]byte, length)