Simplify: use rand.Read instead of io.ReadFull.

This commit is contained in:
Dmitry Chestnykh 2015-01-21 21:36:57 +01:00
parent c1f1da6c92
commit 69450cc2a9

View File

@ -22,10 +22,7 @@
// read from it. // read from it.
package uniuri package uniuri
import ( import "crypto/rand"
"crypto/rand"
"io"
)
const ( const (
// StdLen is a standard length of uniuri string to achive ~95 bits of entropy. // StdLen is a standard length of uniuri string to achive ~95 bits of entropy.
@ -65,7 +62,7 @@ func NewLenChars(length int, chars []byte) string {
maxrb := 256 - (256 % clen) maxrb := 256 - (256 % clen)
i := 0 i := 0
for { for {
if _, err := io.ReadFull(rand.Reader, r); err != nil { if _, err := rand.Read(r); err != nil {
panic("error reading from random source: " + err.Error()) panic("error reading from random source: " + err.Error())
} }
for _, rb := range r { for _, rb := range r {