From 69450cc2a9ee1e0aa0da14510c8e39d01e2275bc Mon Sep 17 00:00:00 2001 From: Dmitry Chestnykh Date: Wed, 21 Jan 2015 21:36:57 +0100 Subject: [PATCH] Simplify: use rand.Read instead of io.ReadFull. --- uniuri.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/uniuri.go b/uniuri.go index 3981c00..1852b81 100644 --- a/uniuri.go +++ b/uniuri.go @@ -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 {