Skip to content

Commit

Permalink
Change the name of the hashCore method to SumSectionReader so that it… (
Browse files Browse the repository at this point in the history
#13)

* Change the name of the hashCore method to SumSectionReader so that it can be used by external callers.

* Retaining hashCore method

---------

Co-authored-by: Andy Gorman <andyg@apacesystems.com>
  • Loading branch information
agorman and Andy Gorman authored Jun 2, 2024
1 parent 883d466 commit 6312005
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions imohash.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ func Sum(data []byte) [Size]byte {
return imo.Sum(data)
}

// SumSectionReader hashes a SectionReader using default sample parameters.
func SumSectionReader(sr *io.SectionReader) ([Size]byte, error) {
imo := New()
return imo.hashCore(sr)
}

// Sum hashes a byte slice using the ImoHash parameters.
func (imo *ImoHash) Sum(data []byte) [Size]byte {
sr := io.NewSectionReader(bytes.NewReader(data), 0, int64(len(data)))
Expand Down Expand Up @@ -87,6 +93,11 @@ func (imo *ImoHash) SumFile(filename string) ([Size]byte, error) {
return imo.hashCore(sr)
}

// SumSectionReader hashes a SectionReader using the ImoHash parameters.
func (imo *ImoHash) SumSectionReader(f *io.SectionReader) ([Size]byte, error) {
return imo.hashCore(f)
}

// hashCore hashes a SectionReader using the ImoHash parameters.
func (imo *ImoHash) hashCore(f *io.SectionReader) ([Size]byte, error) {
var result [Size]byte
Expand Down

0 comments on commit 6312005

Please # to comment.