diff options
| author | Mikhail Osipov <mike.osipov@gmail.com> | 2020-02-23 21:34:21 +0300 |
|---|---|---|
| committer | Mikhail Osipov <mike.osipov@gmail.com> | 2020-02-23 21:34:21 +0300 |
| commit | c573d3e50f39f9352e62d552b07f70f73e6f87dc (patch) | |
| tree | 7db8e9683df8c377e600745ae4ea42231f9075fb /pkg/server | |
| parent | 313241616373ad01413e20758b6edb36afc2762b (diff) | |
auth: use raw binary data
Diffstat (limited to 'pkg/server')
| -rw-r--r-- | pkg/server/module/auth.go | 12 |
1 files changed, 3 insertions, 9 deletions
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 { |
