From 9c8cec0736e672ba0024938c5e940c8f709d7ee2 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Wed, 27 Jul 2016 23:47:22 +0200 Subject: Update PeerID --- peer/id.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'peer/id.go') diff --git a/peer/id.go b/peer/id.go index dd0ff1d..fa8c6a9 100644 --- a/peer/id.go +++ b/peer/id.go @@ -5,11 +5,10 @@ import ( "encoding/hex" ) -func NewID() (string, error) { - r := make([]byte, 10) - _, err := rand.Read(r) - if err != nil { - return "", err - } - return hex.EncodeToString(r), nil +func NewID() []byte { + src := make([]byte, 10) + dst := make([]byte, hex.EncodedLen(len(src))) + rand.Read(src) + hex.Encode(dst, src) + return dst } -- cgit v1.2.3