From 7644a12dd8fbeb0c936848a4bc5cef423a8fc2b7 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Thu, 29 Jan 2026 21:17:25 +0100 Subject: hash: Make streaming hashes possible --- packed_write_pack.go | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'packed_write_pack.go') diff --git a/packed_write_pack.go b/packed_write_pack.go index aa5b7aa0..7e79b2ef 100644 --- a/packed_write_pack.go +++ b/packed_write_pack.go @@ -2,8 +2,6 @@ package furgit import ( "crypto/rand" - "crypto/sha1" - "crypto/sha256" "encoding/binary" "errors" "hash" @@ -29,7 +27,7 @@ func newPackWriter(w io.Writer, algo hashAlgorithm, objCount uint32) (*packWrite if w == nil { return nil, ErrInvalidObject } - h, err := newHashWriter(algo) + h, err := algo.New() if err != nil { return nil, err } @@ -41,17 +39,6 @@ func newPackWriter(w io.Writer, algo hashAlgorithm, objCount uint32) (*packWrite }, nil } -func newHashWriter(algo hashAlgorithm) (hash.Hash, error) { - switch algo { - case hashAlgoSHA1: - return sha1.New(), nil - case hashAlgoSHA256: - return sha256.New(), nil - default: - return nil, ErrInvalidObject - } -} - func (pw *packWriter) writePacked(p []byte) error { if len(p) == 0 { return nil -- cgit v1.3.1-10-gc9f91