From 58f950109fe17126674aca7c8fe31e4903463147 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Tue, 12 Apr 2022 16:55:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96checksum?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gold/head/packet.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gold/head/packet.go b/gold/head/packet.go index 0e2538c..e1afca2 100644 --- a/gold/head/packet.go +++ b/gold/head/packet.go @@ -137,7 +137,7 @@ func (p *Packet) FillHash() { logrus.Error("[packet] err when fill hash:", err) return } - _ = h.Sum(p.Hash[:]) + _ = h.Sum(p.Hash[:0]) } // IsVaildHash 验证 packet 合法性 @@ -149,7 +149,8 @@ func (p *Packet) IsVaildHash() bool { return false } var sum [32]byte - _ = h.Sum(sum[:]) - logrus.Debugln("[packet] sum really:", hex.EncodeToString(sum[:]), "sum in hash:", hex.EncodeToString(p.Hash[:])) + _ = h.Sum(sum[:0]) + logrus.Debugln("[packet] sum calulated:", hex.EncodeToString(sum[:])) + logrus.Debugln("[packet] sum in packet:", hex.EncodeToString(p.Hash[:])) return sum == p.Hash }