From e810e021c717a2dc10cc25c286cc720bc632f548 Mon Sep 17 00:00:00 2001 From: Dmitry Chestnykh Date: Tue, 5 Apr 2011 21:52:50 +0200 Subject: [PATCH] Use io.ReadFull to read from random source. --- uniuri.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/uniuri.go b/uniuri.go index d487298..a4d6bbd 100644 --- a/uniuri.go +++ b/uniuri.go @@ -16,6 +16,7 @@ package uniuri import "crypto/rand" +import "io" const ( // Standard length of uniuri string to achive ~95 bits of entropy. @@ -44,7 +45,7 @@ func NewLen(length int) string { // of the provided byte slice of allowed characters (maximum 256). func NewLenChars(length int, chars []byte) string { b := make([]byte, length) - if _, err := rand.Read(b); err != nil { + if _, err := io.ReadFull(rand.Reader, b); err != nil { panic("error reading from random source: " + err.String()) } alen := byte(len(chars))