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.
package uniuri
import (
"crypto/rand"
"io"
)
import "crypto/rand"
const (
// 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)
i := 0
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())
}
for _, rb := range r {