Skip to content

Commit

Permalink
Added more encoding/binary methods
Browse files Browse the repository at this point in the history
  • Loading branch information
abates committed Jul 25, 2018
1 parent 187d86c commit 1d3adef
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ func Hash(img image.Image) (PHash, error) {
return hash, nil
}

func (h PHash) MarshalBinary() ([]byte, error) {
return []byte{byte(h >> 56), byte(h >> 48), byte(h >> 40), byte(h >> 32), byte(h >> 24), byte(h >> 16), byte(h >> 8), byte(h)}, nil
}

func (h PHash) String() string {
return fmt.Sprintf("0x%016x %064b", uint64(h), uint64(h))
}

0 comments on commit 1d3adef

Please sign in to comment.