mirror of
https://github.com/restic/restic.git
synced 2026-11-14 06:44:03 +00:00
Generalize hash in backend
This commit is contained in:
1 parent
5f0cce8546
commit
842dea173c
2 files changed
+11
-5
No files matched your search
+8
-1
@@ -19,6 +19,13 @@ var (
|
||||
ErrMultipleIDMatches = errors.New("multiple IDs with prefix found")
|
||||
)
|
||||
|
||||
var (
|
||||
newHash = sha256.New
|
||||
hashData = sha256.Sum256
|
||||
)
|
||||
|
||||
const hashSize = sha256.Size
|
||||
|
||||
// Each lists all entries of type t in the backend and calls function f() with
|
||||
// the id and data.
|
||||
func Each(be interface {
|
||||
@@ -92,7 +99,7 @@ func Uncompress(data []byte) []byte {
|
||||
|
||||
// Hash returns the ID for data.
|
||||
func Hash(data []byte) ID {
|
||||
h := sha256.Sum256(data)
|
||||
h := hashData(data)
|
||||
id := idPool.Get().(ID)
|
||||
copy(id, h[:])
|
||||
return id
|
||||
|
||||
Reference in new issue
Block a user