From 732c01e36cb7b870474438a796515f0ed335a2fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B6=9B?= Date: Sun, 16 Jul 2023 11:21:30 +0800 Subject: [PATCH] =?UTF-8?q?fix(hash):=E4=BF=AE=E6=AD=A3Sha256=E7=AE=97?= =?UTF-8?q?=E6=B3=95=E4=B8=AD=E5=87=BA=E7=8E=B0=E7=9A=84=E4=BD=8D=E6=95=B0?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E9=94=99=E8=AF=AF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hash/sha256/sha256.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hash/sha256/sha256.go b/hash/sha256/sha256.go index aa26dc0..6234924 100644 --- a/hash/sha256/sha256.go +++ b/hash/sha256/sha256.go @@ -46,8 +46,7 @@ func Sha256_224Hex(data []byte) string { // 根据给定位数计算一个字节数组的Sha256校验和,返回字节数组。 func Sum256(data []byte, bitSize ...int) []byte { - length := append(bitSize, 256) - hasher := hasherSelect(length[0]) + hasher := hasherSelect(append(bitSize, 256)[0]) hasher.Write(data) return hasher.Sum(nil) } @@ -65,7 +64,7 @@ func SumFile256(file string, bitSize ...int) ([]byte, error) { } defer f.Close() - hasher := hasherSelect(bitSize[0]) + hasher := hasherSelect(append(bitSize, 256)[0]) if _, err := io.Copy(hasher, f); err != nil { return nil, fmt.Errorf("未能读取指定文件的内容,%w", err) }