From c573d3e50f39f9352e62d552b07f70f73e6f87dc Mon Sep 17 00:00:00 2001 From: Mikhail Osipov Date: Sun, 23 Feb 2020 21:34:21 +0300 Subject: auth: use raw binary data --- pkg/server/module/auth.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'pkg/server/module/auth.go') diff --git a/pkg/server/module/auth.go b/pkg/server/module/auth.go index f167874..d4bc8b3 100644 --- a/pkg/server/module/auth.go +++ b/pkg/server/module/auth.go @@ -3,7 +3,6 @@ package module import ( "crypto/md5" "crypto/rand" - "encoding/hex" "errors" "fmt" "io" @@ -43,10 +42,7 @@ func (a *auth) generateChallenge() error { return err } - c := make([]byte, hex.EncodedLen(len(b))) - hex.Encode(c, b) - - a.challenge.self = string(c) + a.challenge.self = string(b) return nil } @@ -59,13 +55,11 @@ func (a *auth) sendChallenge(q queue.Q) bool { func (a *auth) getHash(c string) string { h := md5.New() + io.WriteString(h, a.secret) io.WriteString(h, c) - b := make([]byte, hex.EncodedLen(h.Size())) - hex.Encode(b, h.Sum(nil)) - - return string(b) + return string(h.Sum(nil)) } func (a *auth) sendHash(q queue.Q) bool { -- cgit v1.2.3-70-g09d2